栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Springboot 阿里云服务器 发送 邮件问题

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Springboot 阿里云服务器 发送 邮件问题

在本地中能够发送邮箱,部署到阿里云却发不了???

原本的application.properties邮箱配置

# 邮件协议
spring.mail.protocol=smtp
# 网易邮箱 smtp 服务器地址
spring.mail.host=smtp.163.com
spring.mail.port=25
# 发送人邮箱地址
spring.mail.username=xxxxx@163.com
# 授权码
spring.mail.password=xxxxxxxxxx
# 编码字符集
spring.mail.default-encoding=utf-8
# 开启debug模式用户会完整打印邮件发送过程的日志
spring.mail.properties.mail.debug=true

无需改动前面配置,只需在后面加上

# 以下为配置阿里云服务器发送邮件
spring.mail.properties.mail.smtp.ssl.trust=smtp.163.com
#SSL证书Socket工厂
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

端口问题:发邮件的SMTP的协议默认是25端口,在网上查询资料发现阿里云是封掉了25端口的
我们只需要把端口号改成465端口,然后给它一个ssl证书即可

qq邮箱同理:

#邮件配置
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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/584272.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号