当我运行客户端时,它应该发送一封电子邮件到我的服务器,然后我想让我的电子邮件服务器将电子邮件的详细信息(到,从,端口,消息)打印到控制台。出于某种原因运行客户端后,服务器上没有任何明显的情况发生。subethasmtp服务器不打印来自客户端的消息
服务器
package example;
import org.subethamail.smtp.server.SMTPServer;
public class EmailServer {
public static void main(String[] args) {
MyMessageHandlerFactory myFactory = new MyMessageHandlerFactory();
SMTPServer smtpServer = new SMTPServer(myFactory);
smtpServer.setPort(25000);
smtpServer.start();
}
}
服务器输出
运行:[主要] INFO org.subethamail.smtp.server.SMTPServer - SMTP服务器 *:25000开始[有机subethamail.smtp.server.ServerThread *:25000] INFO org.subethamail.smtp.server.ServerThread - SMTP服务器*:25000 开始
客户
package example;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.subethamail.smtp.client.*;
public class EmailClient {
public static void main(String[] args) {
try {
SMTPClient sc = new SMTPClient();
sc.close();
sc.connect("localhost", 25000);
sc.sendReceive("test");
} catch (IOException ex) {
Logger.getLogger(EmailClient.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
客户端输出
运行:BUILD SUCCESSFUL(总时间:0秒)
2014-12-28
ThreaT