1.先去qq邮箱设置smtp开启,并获得授权码
邮箱->设置->账户->POP3/SMTP服务:开启服务后会获得授权码
2.引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
3.修改配置文件
spring: mail: host: smtp.qq.com #配置服务器 qq:smtp.qq.com 网易:smtp.163.com username: #自己邮箱地址 password: #授权码 邮箱->设置->账户->POP3/SMTP服务:开启服务后会获得权码 default-encoding: UTF-8
4.编写程序,发送邮件
或