本依赖已发布至 Maven 中央仓库, 可以访问:Reactive-Email-Sender, 也可以在 pom.xml 中直接配置:
1.1.5 版本完成了模块化迁移, 以及更细粒度的参数控制,强烈建议使用新版。
<dependency>
<groupId>io.github.jessez332623</groupId>
<artifactId>reactive_email_sender</artifactId>
<version>1.1.5</version>
</dependency># 是否启用本依赖?(默认启用)
app.reactive-email-sender.enabled=true
# 提供 SMTP 服务的运营商主机名
app.reactive-email-sender.smtp-host=smtp.qq.com
# SMTP 端口号
app.reactive-email-sender.smtp-port=465
# 最大邮件发送尝试次数(默认 3 回)
app.reactive-email-sender.backoff.max-attempt-times=5
# 指数退避起始时间间隔(单位:秒,默认为 1)
app.reactive-email-sender.backoff.start-backoff-interval=2
# 指数退避封顶时间间隔(单位:秒,默认为 10)
app.reactive-email-sender.backoff.max-backoff-interval=5
# 附件大小的上限(单位:MB,默认为 8)
app.reactive-email-sender.max-attachment-size=8
# 发件人邮箱地址
app.reactive-email-sender.sender-email=[your-email]
# 邮箱服务授权码(不建议直接写配置上)
app.reactive-email-sender.auth-code=[your-auth-code]
# 额外的 Session 属性添加示例
app.reactive-email-sender.session-props.mail.smtp.ssl.enable=true
app.reactive-email-sender.session-props.mail.smtp.auth=true
app.reactive-email-sender.session-props.mail.smtp.connectiontimeout=5000本依赖声明 EmailServiceAuthCodeGetter 接口:
/**
* 邮箱服务授权码获取接口,
* 用户可以实现该接口,从任何地方(如:环境变量、数据库等)获取授权码。
*/
public interface EmailServiceAuthCodeGetter
{
default String get() { return null; }
}可以实现该接口,示例如下(从数据库读取授权码):
@Service
public class EmailAuthService implements EmailServiceAuthCodeGetter
{
@Autowired
private EmailAuthRepository emailAuthRepository;
@Value("${app.reactive-email-sender.sender-email}")
private String senderEmail;
@Override
public String get()
{
return
this.emailAuthRepository
.findAuthCodeByEmail(senderEmail)
.block();
}
}2025.09.26