下面是我正在使用的代码:
Properties props = System.getProperties();
props.put("mail.smtp.auth", "true");
// props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", server);
props.put("mail.smtp.port", "25");
Session session = Session.getInstance(props);
Transport transport = null;
try {
transport = session.getTransport("smtp");
session.setDebug(true);
transport.connect(server, username, password);
} catch(AuthenticationFailedException message){
System.out.println("Authentication Failed... terminating!");
System.out.println(message);
System.exit(16);
}
不幸的是,我没有看到会话握手。我是否将 setDebug 放在错误的位置?