当前位置:   article > 正文

SpringBoot实现邮件发送邮报错:AuthenticationFailedException:535 Login Fail. Please enter your authorization c_authenticationfailedexception: 535 login fail. ple

authenticationfailedexception: 535 login fail. please enter your authorizati

需求背景

  1. 因项目需求,需要实现Java发送邮件预警,这里简单的做一个spring boot项目实现Java发送邮件示例(简单调通);
  2. 发送邮箱:xxx@qq.com,配置项都和邮箱有关,比如qq邮箱发送和网易邮箱发送的配置就不一样;
  3. 接受邮箱:不规定;
  4. 项目是sprint boot项目;

邮箱授权码错误 报错如下

Authentication failed;nested exception is javax.mail.AuthenticationFailedException:535 
Login Fail. Please enter your authorization code to login.More information in 
http://service.mail.qq.com/cgi- bin/help?subtype=1&&id=28&&no=1001256
  • 1
  • 2
  • 3

使用邮箱密码而非生成的授权码

org.springframework.mail.MailAuthenticationException: Authentication failed; 
    nested exception is javax.mail.AuthenticationFailedException: 535 Login Fail. 
    Please enter your authorization code to login. 
    More information in http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
  • 1
  • 2
  • 3
  • 4

邮箱未开启POP3/SMTP服务

org.springframework.mail.MailAuthenticationException: Authentication failed; 
    nested exception is javax.mail.AuthenticationFailedException: 535 Login Fail. 
    Please enter your authorization code to login. 
    More information in http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
  • 1
  • 2
  • 3
  • 4

报错原因:

工具类中:PASSWORD 填的要填写邮箱客户端授权码才行

private static final String USER = "6666666@qq.com"; // 发件人邮箱地址

private static final String PASSWORD = "*********"; // 填写自己客户端授权码
  • 1
  • 2
  • 3

所以打开自己的邮箱生成相应的授权码进行填写,问题就能解决了

在这里插入图片描述

如何拿到QQ邮箱生成相应的授权码

进入 QQ 邮箱网页版 按照如下顺序分别开启服务功能
在这里插入图片描述
在这里插入图片描述
开启服务功能后 会生成一个授权登录码如下:
在这里插入图片描述
然后将生成的授权码 放到前面的工具类中就可以进行开发啦

发送邮件成功!
在这里插入图片描述
另一边成功接受邮件!
在这里插入图片描述
手机端也收到了
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/601946
推荐阅读
相关标签
  

闽ICP备14008679号