小弟想问一下我在本地启动了 james的这个邮件服务 然后在 MyEclipse中创建了一个Mail项目 里面有一个类是专门查看邮件的
package com.mail.util;import java.io.*;
import java.net.Socket;public class POP3Demo {
private static String POP3Server = "pop3.163.com";
private static String USERNAME = "zhang_shubin";//实际应用中改成真实的用户名
private static String PASSWORD = "36876934ok";//实际应用中改成真实的密码
public static void main(String[] args) throws IOException {
System.out.println(new String((new sun.misc.BASE64Decoder()).decodeBuffer("ZGZkZmRm")));
int POP3Port = 110;
Socket client = null;
try {
// 向POP3服务程序建立一个套接字连接。
client = new Socket(POP3Demo.POP3Server, POP3Port);
// 创建一个BufferedReader对象,以便从套接字读取输出。
InputStream is = client.getInputStream();
BufferedReader sockin = new BufferedReader(new InputStreamReader(is));
// 创建一个PrintWriter对象,以便向套接字写入内容。
OutputStream os = client.getOutputStream();
PrintWriter sockout = new PrintWriter(os, true);
// 显示同SMTP服务程序的握手过程。
System.out.println("S:" + sockin.readLine());
sockout.println("user " + POP3Demo.USERNAME);
System.out.println("S:" + sockin.readLine());
sockout.println("pass " + POP3Demo.PASSWORD);
System.out.println("S:" + sockin.readLine());
sockout.println("stat");
String temp[] = sockin.readLine().split(" ");
int count = Integer.parseInt(temp[1]);//得到信箱中共有多少封邮件
for (int i = 1; i < count + 1; i++) {//依次打印出邮件的内容
sockout.println("retr " + i);
System.out.println("以下为第" + i + "封邮件的内容");
while (true) {
String reply = sockin.readLine();
System.out.println(reply);
if (reply.toLowerCase().equals(".")) {
break;
}
}
} } catch (IOException e) {
System.out.println(e.toString());
} finally {
try {
if (client != null) {
client.close();
}
} catch (IOException e) {}
}
}
}因为连接到163.com 总是提示没有权限
所以我启动本地java的james邮件服务 我把 private static String POP3Server = "pop3.163.com";改成 ="pop3.localhost" 还是出错
请问上面的代码需要改哪里啊
package com.mail.util;import java.io.*;
import java.net.Socket;public class POP3Demo {
private static String POP3Server = "pop3.163.com";
private static String USERNAME = "zhang_shubin";//实际应用中改成真实的用户名
private static String PASSWORD = "36876934ok";//实际应用中改成真实的密码
public static void main(String[] args) throws IOException {
System.out.println(new String((new sun.misc.BASE64Decoder()).decodeBuffer("ZGZkZmRm")));
int POP3Port = 110;
Socket client = null;
try {
// 向POP3服务程序建立一个套接字连接。
client = new Socket(POP3Demo.POP3Server, POP3Port);
// 创建一个BufferedReader对象,以便从套接字读取输出。
InputStream is = client.getInputStream();
BufferedReader sockin = new BufferedReader(new InputStreamReader(is));
// 创建一个PrintWriter对象,以便向套接字写入内容。
OutputStream os = client.getOutputStream();
PrintWriter sockout = new PrintWriter(os, true);
// 显示同SMTP服务程序的握手过程。
System.out.println("S:" + sockin.readLine());
sockout.println("user " + POP3Demo.USERNAME);
System.out.println("S:" + sockin.readLine());
sockout.println("pass " + POP3Demo.PASSWORD);
System.out.println("S:" + sockin.readLine());
sockout.println("stat");
String temp[] = sockin.readLine().split(" ");
int count = Integer.parseInt(temp[1]);//得到信箱中共有多少封邮件
for (int i = 1; i < count + 1; i++) {//依次打印出邮件的内容
sockout.println("retr " + i);
System.out.println("以下为第" + i + "封邮件的内容");
while (true) {
String reply = sockin.readLine();
System.out.println(reply);
if (reply.toLowerCase().equals(".")) {
break;
}
}
} } catch (IOException e) {
System.out.println(e.toString());
} finally {
try {
if (client != null) {
client.close();
}
} catch (IOException e) {}
}
}
}因为连接到163.com 总是提示没有权限
所以我启动本地java的james邮件服务 我把 private static String POP3Server = "pop3.163.com";改成 ="pop3.localhost" 还是出错
请问上面的代码需要改哪里啊
实现YourMailet extends GenericMailet,同时James的config文件要加几行配置你Google下JamesMailet。