本文主要是介绍springboot mail发送邮件无法收到邮件,553 Local user is not allowed,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用springboot的email发送邮件,
gradle 中加入依赖
compile("org.springframework.boot:spring-boot-starter-mail:2.+")
application.yml配置如下:
spring:mail:host: smtp.163.com #发送邮件服务器username: xgct0505@163.com #163邮箱账号password: test12345 #授权码protocol: smtp #发送邮件协议properties.mail.smtp.auth: trueproperties.mail.smtp.port: 994 #端口号465或994properties.mail.smtp.starttls.enable: trueproperties.mail.smtp.starttls.required: trueproperties.mail.smtp.ssl.enable: trueproperties.mail.debug: truedefault-encoding: utf-8
发邮件程序:
@RestController
public class TestEmailController {@Autowiredprivate JavaMailSender javaMailSender;@RequestMapping("/emailTest")public String testEmail() throws MessagingException {final MimeMessage mimeMessage = this.javaMailSender.createMimeMessage();final MimeMessageHelper message = new MimeMessageHelper(mimeMessage);message.setFrom("xgct0505@163.com");message.setTo("susan@qq.com");message.setSubject("邮件主题");message.setText("邮件内容");this.javaMailSender.send(mimeMessage);return "success";}
}
一切准备妥当后点击测试,发现不报错,但就是怎么也收不到邮件,还好在163邮箱里面收到退信,退信内容如下:
在退信内容最重要的一句话就是:553 Local user is not allowed,通过搜索,大概明白了它的意思是指发件邮箱不能是本地用户,所谓本地用户也就是邮箱后缀为@163.com的用户,于是把改了下发件人,就可以收到邮件了
message.setFrom("xgct0505@qq.com");
参考文章:
向网易邮箱发信常见退信说明
这篇关于springboot mail发送邮件无法收到邮件,553 Local user is not allowed的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!