Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: smtp.163.com, port: 25;
nested exception is:
javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2212)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:722)
at javax.mail.Service.connect(Service.java:342)
at javax.mail.Service.connect(Service.java:222)
at javax.mail.Service.connect(Service.java:243)
at com.ailpha.aithink.job.controller.email.EmailUtil.deliverWithMime(EmailUtil.java:68)
at com.ailpha.aithink.job.controller.email.EmailUtil.main(EmailUtil.java:149)
The reason is that the following code is used when SSL is enabled
if (emailConfigModel.getEnSsl() == 0) {
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
prop.put("mail.smtp.ssl.enable", "true");
prop.put("mail.smtp.ssl.socketFactory", sf);
}
After searching various data, it is found that the port used when using SSL is port 465, not port 25. If SSL is not used, the port is port 25