邮箱发送报错问题
在项目中使用JavaMailSender发送邮件时程序报错:
nested exception is javax.mail.AuthenticationFailedException: 535 Error: authentication failed
经检查,服务开启了
原因
在yml文件配置邮箱时,将password配置成了邮箱登录密码,而实际是要填你开启服务时获得的授权码
spring:
mail: # 邮箱配置
host: smtp.163.com
port: 465
username: 发件人邮箱账号
password: 原先这里填的是邮箱登录密码,错误!
protocol: smtps
properties.mail.smtp.ssl.enable: true
解决方案
password配置为授权码,再次测试,错误解决
spring:
mail: # 邮箱配置
host: smtp.163.com
port: 465
username: 发件人邮箱账号
password: 应该填邮箱smtp服务授权码
protocol: smtps
properties.mail.smtp.ssl.enable: true