SpringBoot 邮件任务(spring-boot-starter-mail)
1,Spring Boot 邮件发送需要在pom文件中引入spring-boot-starter-mail
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
2,在application.properties中配置邮件属性,邮件属性内容可在MailProperties类中查找
#发送邮件服务器,可以在邮箱的“POP3/SMTP服务”查看
spring.mail.host=smtp.qq.com
#邮箱密码经过加密的,需要在邮箱中发送短信获取。
spring.mail.password=mfcozdmaumowndwrr
#邮箱
spring.mail.username=123@qq.com
#出现530错误需开启
#spring.mail.properties.mail.smtp.ssl.enable=true
3,利用自动装配JavaMailSender发送邮件
@RunWith(SpringRunner.class)
@SpringBootTest
public class ThymeleaftestApplicatio