当前位置:   article > 正文

javamail “535 5.7.3 Authentication unsuccessful“ 问题排查_javax.mail.authenticationfailedexception: 535 5.7.

javax.mail.authenticationfailedexception: 535 5.7.3 authentication unsuccess
有一家odm的服务器用Javamail发邮件的时候报错  Authentication unsuccessful  其他的有些又是正常的

 

网上查了一下解决方法如下

 

JavaMailSenderImpl认证异常了,出现:javax.mail.AuthenticationFailedException: failed to connect的异常,
将JAVAMAIL的DEBUG日志打开,通过properties.setProperty("mail.debug", "true");可以看到出现了535 5.7.3 Authentication unsuccessful的问题,需要增加以下设置:
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.auth.mechanisms", "NTLM");

就可以解决了,如果非WINDOWS操作系统,需要将NTLM修改为digest方式;
具体代码如下:
JavaMailSenderImpl senderImpl = new JavaMailSenderImpl();
Properties properties = new Properties();
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.auth.mechanisms", "NTLM");   //如果不行改为digest再试试
//properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); 
properties.setProperty("mail.debug", "true");
senderImpl.setJavaMailProperties(properties);
senderImpl.setHost("IP地址");
senderImpl.setUsername("认证用户邮箱");
senderImpl.setPassword("对应的邮箱密码");
//senderImpl.setPort(25);

MimeMessage mailMessage = senderImpl.createMimeMessage();
MimeMessageHelper messageHelper = new MimeMessageHelper(mailMessage,
true, "GBK");
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/602058
推荐阅读
相关标签
  

闽ICP备14008679号