当我运行客户端时,它应该发送一封电子邮件到我的服务器,然后我想让我的电子邮件服务器将电子邮件的详细信息(到,从,端口,消息)打印到控制台。出于某种原因运行客户端后,服务器上没有任何明显的情况发生。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秒)
版是从https://code.google.com/p/subethasmtp/downloads/list3.1.7
服务器需要MyMessageHandlerFactory这是我从复制:https://code.google.com/p/subethasmtp/wiki/SimpleExample
哦,关于你的'IOException' try/catch,事务不会失败。相反,如果您选择关注它,它会尽职尽责地回报您的问题。 :-) –
所以,我是这个图书馆的全新人物,从未碰过它。为了让我的服务器打印出客户端的电子邮件,你可以告诉我需要做哪些基本的代码级别更改? – ThreaT
只需跟进,有没有机会看看我以前的评论? – ThreaT