Java 实现发送邮件

 

javax.mail.AuthenticationFailedException: 530 Error: A secure connection is requiered(such as ssl). More information at http://service.mail.qq.com/cgi-bin/help?id=28

在java发送邮件的时候,出现了这个错误。

原因:QQ邮箱需要证书认证。

解决办法:

在原代码中加入下面代码

  1.  // 进行证书认证   
  2.                 MailSSLSocketFactory sf = new MailSSLSocketFactory();  
  3.                 sf.setTrustAllHosts(true);  
  4.                 properties.put("mail.smtp.ssl.enable", "true");  
  5.                 properties.put("mail.smtp.ssl.socketFactory", sf); 
posted @ 2018-06-06 18:22  胖头陀春天  阅读(164)  评论(0编辑  收藏  举报