项目GitHub地址 :
https://github.com/FrameReserve/TrainingBoot
https://github.com/FrameReserve/TrainingBoot/releases/tag/0.0.12
pom.xml
增加:
spring-boot-starter-mail
spring-boot-starter-velocity -- 模板
<!-- Email -->
<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>
Spring Boot配置文件:
QQ邮箱权限需要在QQ邮箱里设置,163则不用,问题比较少。
src/main/resources/application.yml
mail:
host: smtp.163.com
username: 286352250@163.com
password: 用户密码
properties:
mail:
smtp:
auth: true
timeout: 25000
Email配置类:
后期经常使用发件人邮箱,在这统一定义。
src/main/java/com/training/core/email/EmailConfig.java
package com.training.core.email;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereot