一 点睛
使用过Spring的众多开发者都知道Spring提供了非常好用的JavaMailSender接口实现邮件发送。
在Spring Boot的Starter模块中也为此提供了自动化配置。
下面通过实例看看如何在Spring Boot中使用JavaMailSender发送邮件。
二 实战
1 引入相关依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
2 application.properties配置
spring.mail.host=smtp.qq.com
[email protected]
spring.mail.password=授权登录密码
spring.mail.properties.mail.smtp.auth=true
spri