1、pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency>
2、(参考https://www.jianshu.com/p/c12ce66ec7be)
2.1.发送qq邮箱
#JavaMailSender 邮件发送的配置
spring.mail.host=smtp.qq.com
spring.mail.username=393156105@qq.com
spring.mail.password=tdckceislhfibhbbb
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.password
处的值是需要在邮箱设置里面生成的授权码
,这个不是真实的密码。
- 发送简洁邮件(在测试类testxxx中)
@Autowired
private JavaMailSender javaMailSender;
@Value