本文通过SpringBoot整合Email和Quartz来实现定时发送邮件的功能;最终效果是每天上午10:30向某人发送一封邮件。
首先,导入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- quartz依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
配置文件
spring:
mail:
host: smtp.qq.com
username: 123456@qq.com #邮箱
password: ************* #授权码
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
业务逻辑层代码: