<分区>
Properties props = new Properties();
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", SMTPHost);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "587");
Authenticator Auth= new MailAuthenticator();
Session session = Session.getInstance(props, Auth);
MimeMessage msg = new MimeMessage(session);
//
//
Transport.send(msg);
邮件大部分时间发送成功,但有时发送不成功,tomcat显示
javax.mail.MessagingException: Could not connect to SMTP host: "SMTPHost - IP " , port: 587;
嵌套异常是: java.net.ConnectException:连接超时:连接
此消息每隔几个小时就会出现在 Tomcat 日志中。
javax.mail.MessagingException:读取响应异常; 嵌套异常是: java.net.SocketException: 连接重置
This message also appears rarely in a day.
非常感谢任何帮助。谢谢。