SpringBoot项目本地可以发送邮件,部署到阿里云服务器发送邮件失败的解决方法
在application.yml文件中配置
#邮件设置 spring: mail: host: smtp.exmail.qq.com port: 465 username: xxx@qq.com password: xxx default-encoding: UTF-8 #配置阿里云服务器发送邮件 properties: mail: smtp: ssl: trust: smtp.exmail.qq.com socketFactory: class: javax.net.ssl.SSLSocketFactory port: 465 auth: true starttls: enable: true required: true
或在application.properties中配置
#邮件配置 spring.mail.host=smtp.exmail.qq.com spring.mail.port=465 spring.mail.username=xxx@qq.com spring.mail.password=xxx spring.mail.default-encoding=UTF-8 #配置阿里云服务器发送邮件 spring.mail.properties.mail.smtp.ssl.trust=smtp.exmail.qq.com spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory 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