一、获取授权码
1、以QQ邮箱为例,页面首部找到设置
2、开启POP3/SMTP服务
3、获取授权码
二、SpringBoot集成邮件发送
1、环境配置
-
添加依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> <version>${springboot.version}</version> </dependency>
-
application.properties
邮件
spring.mail.default-encoding= utf-8
配置 SMTP 服务器地址
spring.mail.host= smtp.qq.com
#发送方邮件名
spring.mail.username= xxxx@qq.com
#授权码
spring.mail.password= xxxxxx
邮箱类型
SMTP服务器地址
端口号
QQ邮箱
smtp.qq.com
465或587
sina邮箱
smtp.sina.cn
465或587
126邮箱
sm