SpringBoot 整合Mail发送功能问题与解决
2017-01-08 17:45
567 查看
SpringBootLean 是对springboot学习与研究项目,是根据实际项目的形式对进行配置与处理,欢迎star与fork。
[oschina 地址]
http://git.oschina.net/cmlbeliever/SpringBootLearning
[github 地址]
https://github.com/cmlbeliever/SpringBootLearning
在项目中,发送邮件功能还是非常常见的,最近将邮件功能整合到springboot中,代码已经提交到branch-mail分支上,具体事项请查看README.MD上的说明。
这里记录下整合邮件功能遇到的问题与解决办法。
第一步 导入引入相关jar
第二步 在config/application.properties上配置相关信息,这里demo用的是163邮箱
配置完以上信息后就可以直接执行单元测试的了
com.cml.springboot.controller.test.MailSenderTest
具体功能请检出工程后自行测试。
问题1 发送邮件535错误
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535 Error: authentication failed
问题1解决
问题是因为配置文件中配置的邮箱密码是登录密码而不是安全密码导致的,直接将密码修改成安全密码就可以了(163邮箱在开启smtp服务时会要求输入安全密码的)
问题2
554 DT:SPM 163 smtp10,DsCowACXs5lqAXJYldK2GQ–.5581S2 1483866477,please see http://mail.163.com/help/help_spam_16.htm?ip=220.179.147.26&hostid=smtp10&time=1483866477
问题2解决
引发次问题是因为此邮件触发了163邮箱服务器反垃圾规则,测试邮件发送的内容是:”你好!试试”,这样也能出发反垃圾规则,感觉莫名其妙,把内容改为”1111111”,邮件正常发送。所以发送邮件的时候需要具体查看下163邮件的规则。具体原因在错误上已经提示了,到网址:http://mail.163.com/help/help_spam_16.htm?ip=220.179.147.26&hostid=smtp10&time=1483866477上查看即可
[oschina 地址]
http://git.oschina.net/cmlbeliever/SpringBootLearning
[github 地址]
https://github.com/cmlbeliever/SpringBootLearning
在项目中,发送邮件功能还是非常常见的,最近将邮件功能整合到springboot中,代码已经提交到branch-mail分支上,具体事项请查看README.MD上的说明。
这里记录下整合邮件功能遇到的问题与解决办法。
第一步 导入引入相关jar
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>4.3.2.RELEASE</version> </dependency> <!-- https://mvnrepository.com/artifact/javax.mail/mail --> <dependency> <groupId>javax.mail</groupId> <artifactId>mail</artifactId> <version>1.4.7</version> </dependency>
第二步 在config/application.properties上配置相关信息,这里demo用的是163邮箱
spring.mail.from=**@163.com spring.mail.host=smtp.163.com spring.mail.password=邮箱安全密码 spring.mail.properties.smtp.auth=true spring.mail.properties.smtp.timeout=25000 spring.mail.username=**@163.com
配置完以上信息后就可以直接执行单元测试的了
com.cml.springboot.controller.test.MailSenderTest
具体功能请检出工程后自行测试。
问题1 发送邮件535错误
org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535 Error: authentication failed
问题1解决
问题是因为配置文件中配置的邮箱密码是登录密码而不是安全密码导致的,直接将密码修改成安全密码就可以了(163邮箱在开启smtp服务时会要求输入安全密码的)
问题2
554 DT:SPM 163 smtp10,DsCowACXs5lqAXJYldK2GQ–.5581S2 1483866477,please see http://mail.163.com/help/help_spam_16.htm?ip=220.179.147.26&hostid=smtp10&time=1483866477
问题2解决
引发次问题是因为此邮件触发了163邮箱服务器反垃圾规则,测试邮件发送的内容是:”你好!试试”,这样也能出发反垃圾规则,感觉莫名其妙,把内容改为”1111111”,邮件正常发送。所以发送邮件的时候需要具体查看下163邮件的规则。具体原因在错误上已经提示了,到网址:http://mail.163.com/help/help_spam_16.htm?ip=220.179.147.26&hostid=smtp10&time=1483866477上查看即可
相关文章推荐
- 解决SpringBoot 整合 FreeMaker,不能js,css静态资源的问题
- Java发送mail功能,解决中文乱码问题
- Spring Boot整合UEditor,解决找不到上传文件的问题
- springboot邮件发送功能和两个常见问题
- Maven项目中,关于Spring Boot 整合MyBatis时,Service层无法找到mapper接口的问题解决
- SpringBoot开发案例之整合mail发送服务
- 解决SpringBoot整合shiro之后无法加载静态资源文件问题
- spring boot--整合spring session实现session共享以及cookie丢失问题解决
- 关于spring boot整合druid连接池在程序关闭后连接不释放问题解决
- Spring2.5,Activemq5.2整合遇到的问题以及解决方法
- Spring2.5整合Activiti 5.11 解决MalformedParameterizedTypeException问题
- Spring3+MyBatis3整合无法输出SQL语句问题的解决
- JPA与Spring2.5整合时发生不能创建entityManagerFactory的问题解决方法
- 整合jpa和Spring报错问题的解决
- 在整合spring-flex时遇到问题及解决方法
- 使用Outlook发送邮件至移动设备导致移动设备接收winmail.dat问题解决方法
- 实践中遇到Ibatis和spring整合事务不回滚的问题解决
- Spring发送电子邮件发件人中文名乱码问题解决
- MyEclipse 7.0M1 SSH 整合开发问题解决:Spring2.5+hibernate3.1+Struts1.3 +Tomcat6.0
- 终于完全解决了,关于Mail无法发送邮件的问题(转载)