用java实现发送邮件功能时报错
javax.mail.MessagingException: Could not connect to SMTP host文章来源:https://www.toymoban.com/news/detail-598916.html
Exception in thread "main" javax.mail.MessagingException: Could not connect to SMTP host: smtp.suixingpay.com, port: 465, response: -1
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:2041)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:697)
at javax.mail.Service.connect(Service.java:364)
at javax.mail.Service.connect(Service.java:245)
解决办法:
props.put(“mail.smtp.ssl.enable”, true);文章来源地址https://www.toymoban.com/news/detail-598916.html
Properties props = System.getProperties();
props.put("mail.smtp.host", "smtp.suixingpay.com");
props.put("mail.smtp.port", 465);
props.put("mail.smtp.ssl.enable", true);
Session session = Session.getDefaultInstance(props, null);
到了这里,关于解决发邮件错误javax.mail.MessagingException: Could not connect to SMTP host的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!