Java springboot 项目增加一个邮箱验证码功能,本地测试没有问题,上传到服务器上时邮件发送不了。网上搜了一下问题,是因为云服务器禁用了25端口,邮箱的默认端口,通过修改properties文件中的端口号后成功解决。
#邮件发送配置
spring.mail.default-encoding=UTF-8
spring.mail.host=smtp.qq.com
spring.mail.username=1538643358@qq.com
spring.mail.password=dwlkvtdeztysgfae
spring.mail.properties.mail.smtp.ssl.trust=smtp.qq.com
#SSL证书Socket工厂
spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
#使用SMTPS协议465端口
spring.mail.properties.mail.smtp.socketFactory.port=465
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true
spring.mail.properties.mail.smtp.starttls.required=true
spring.mail.smtp.ssl.enable= true
#thymeleaf配置
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.cache=false