解决530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MA
来源:互联网 发布:网络上赌博 编辑:程序博客网 时间:2024/05/21 18:43
使用java调用Office365发送邮件的时候报如下错误:
com.sun.mail.smtp.SMTPSendFailedException:530 5.7.57 SMTP; Client was not authenticated to send anonymous mail duringMAIL FROM
atcom.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2108)
atcom.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1609)
atcom.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1117)
atjavax.mail.Transport.send0(Transport.java:195)
atjavax.mail.Transport.send(Transport.java:124)
atcom.paraview.mail.MailSender.sendTextMail(MailSender.java:60)
atcom.paraview.mail.Test.main(Test.java:10)
分割线------------------------------------------------------------------------------------------------
刚开始我以为是配置错误,因为代码都是在网上找的,复制粘贴而已,现在的程序员都懒 ,我更懒!但是我的代码是之前在其他项目中正常运行过的,也就是说我的代码是正常的,但是为何调用office365就会报错呐?
我尝试了在网上寻找大牛的解决办法,google了几个小时后没有结果,虽然有很多人遇到同样的问题,但是老外给的解决办法也是各种各样,结果是都没有解决我遇到的问题。
邮箱配置如下:
SMTP设置
服务器名称:smtp.outlook.cn
端口:587
加密方法:TLS
我通过Foxmail配置后是可以正常收发邮件的,为何通过代码不可以呐?
从邮箱配置上我可以看到加密方法: TLS ,TLS不是SSL所以我在我的配置上加上了配置
proper.put("mail.smtp.starttls.enable","true");
然后继续运行,发现错误不一样了.
这个错误又是为何?不能通过TLS建立连接,但是明明是TLS啊。网上有一些blog说必须是jdk1.6不能是jdk1.7虽然搞不明白为何,但是索性也把jdk版本换了
结果错误依旧啊!
这个时候索性我就想干脆把所有的配置都加上,看看什么效果,于是我就又加了如下配置:
proper.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
proper.put("mail.smtp.socketFactory.port","587");
proper.put("mail.smtp.socketFactory.fallback","false");
这个时候错误又变了:Could not connect to SMTP host: smtp.partner.outlook.cn, port: 587;
为何连不上578端口,端口是肯定没问题,一定是配置有问题
于是我又加上了配置:
MailSSLSocketFactory sf = newMailSSLSocketFactory();
sf.setTrustAllHosts(true);
proper.put("mail.smtp.ssl.socketFactory",sf);
错误依旧啊!这个时候已经无力吐槽了,继续查,错误里面有一个错误是这个:
Caused by: javax.net.ssl.SSLException: Unrecognized SSLmessage, plaintext connection?
这个是什么错?
于是我又问了下度娘,结果度娘说这个配置mail.smtp.socketFactory.fallback要改成 true 。
于是我就改了配置
proper.put("mail.smtp.socketFactory.fallback","true");
神奇的事情发生了,真的发送成功了!
在这里留一个备份,方便以后参考!
- 解决530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MA
- 解决530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
- Java Mail 530 5.7.1 Client was not authenticated 错误解决
- A Client to Send SMTP Mail
- Smtp Send mail
- python smtp send mail
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- How to Send an Email Using UTL_SMTP with Authenticated Mail Server
- JavaMail 553 You are not authorized to send mail
- javamail javax.mail.MessagingException: Could not connect to SMTP host:
- javax.mail.MessagingException: Could not connect to SMTP host
- AX fail to send mail by SMTP , COM error code 0x80040211, 0x8004020f
- Fixed SMTP Mail Send Validation Error
- Send mail using Gmail SMTP in Magento
- send mail by SMTP server (Python)
- 550 5.7.1 Client does not have permissions to send as this sender
- 解决问题:javax.mail.MessagingException: Could not connect to SMTP host: smtp.exmail.qq.com, port: 25;
- javax.mail.MessagingException: Could not connect to SMTP host: smtp.xx.com, port: 465;
- Unity实现手机录音功能
- 控件解析与实战
- java实现文件夹下解压jar包和zip包
- HDOJ 1033 Edge
- scala-sdk概览
- 解决530 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MA
- 严重: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException
- 水平分库分表的关键问题及解决思路
- css3制作淡出淡入动画
- tensorflow官方文档 mnist进阶(卷积神经网络)
- 重装ubuntu1404系统后的配置
- Linux中qt编写登录
- 菜鸟学习历程【19】进程通信(1)
- LibSVM学习详细说明