发送邮件Javax.mail.AuthenticationFailedException: 530 Error:
2018-03-07 11:44
1716 查看
今天写的小demo里有一个发送QQ邮件验证码的功能。心想着照着以前的代码改就是了(以前用的不是QQ邮箱)。
结果写的时候发现了一个问题,一直会报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的错误。 百度了一下发现如果使用QQ邮箱发送,需要进行SSL加密,如果没有加密,就会报530的错误。
SSL加密代码: //定义Properties对象,设置环境信息
Properties props = new Properties();
try {
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.socketFactory", sf);
} catch (GeneralSecurityException e1) {
e1.printStackTrace();
}加上这段代码后就不会再报530的问题啦~
结果写的时候发现了一个问题,一直会报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的错误。 百度了一下发现如果使用QQ邮箱发送,需要进行SSL加密,如果没有加密,就会报530的错误。
SSL加密代码: //定义Properties对象,设置环境信息
Properties props = new Properties();
try {
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.socketFactory", sf);
} catch (GeneralSecurityException e1) {
e1.printStackTrace();
}加上这段代码后就不会再报530的问题啦~
相关文章推荐
- 转载邮件失败!javax.mail.AuthenticationFailedException: 535 Error: authentication
- javax.mail.AuthenticationFailedException: 530 Error: A secure connection is requiered
- javax.mail.AuthenticationFailedException: 530 Error: A secure connection is requiered
- Spring发送邮件_javax.mail.AuthenticationFailedException异常已解决
- 发送邮件异常:Mail server connection failed; nested exception is javax.mail.MessagingException: 500 Error:
- 邮件失败!javax.mail.AuthenticationFailedException: 535 Error: authentication
- javax.mail.AuthenticationFailedException: 530 Error: A secure connection is requiered(such as ssl).
- 使用mail架包发送邮件javax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connec
- Spring发送邮件_javax.mail.AuthenticationFailedException异常已解决
- 使用mail架包发送邮件javax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connec
- javax.mail.AuthenticationFailedException: 535 Error: authentication failed
- javax.mail.AuthenticationFailedException: 530
- JavaMail中Session.getDefaultInstance的应用 | javax.mail.AuthenticationFailedException: 454 Error
- javax.mail.AuthenticationFailedException: 535 Error: authentication failed
- 邮件发送问题javax.mail.SendFailedException: Sending failed
- log4j发送邮件出现javax.mail.MessagingException: 503 Error: need EHLO and AUTH first !
- 解决使用JavaMail发送邮件报错javax.mail.MessagingException: 500 Error: bad syntax
- java mail SMTP 发送验证代码 javax.mail.AuthenticationFailedException
- 学习笔记——mail发送javax.mail.AuthenticationFailedException: failed to connect at javax.mail.Service.connect(Service.java:322) at javax.mail.Service.connect(Service.java:172) at javax.mail.Service.connect
- javax.mail.AuthenticationFailedException: 535 Error: authentication failed