- 支持文本邮件
- 支持html模板邮件
- 支持cc发送
- 支持文件上传
- 支持自定义邮箱配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
# 邮箱配置
spring:
mail:
host: smtp.163.com
port:
username: [email protected]
password: *********
protocol: smtp
default-encoding: utf-8
test-connection: true
/**
* 内容
*/
private String content;
/**
* 接收者
*/
private String to;
/**
* 发送者
*/
private String from;
/**
* 主题
*/
private String subject;
/**
* cc
*/
private String[] cc;
/**
* 链接文件
*/
private Map<String, File> linkFiles;
/**
* 是否类型为html
*/
private boolean isHtml = false;