Skip to content

Commit

Permalink
refactor: ♻️ 调增邮件配置项及相关实现
Browse files Browse the repository at this point in the history
  • Loading branch information
fxbin committed Oct 11, 2023
1 parent aaebed4 commit 2bd6355
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 130 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cn.fxbin.bubble.mail;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.Data;
import org.dromara.email.comm.config.MailSmtpConfig;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.List;
import java.util.Map;

import static cn.fxbin.bubble.mail.MailProperties.BUBBLE_MAIL_PREFIX;
Expand Down Expand Up @@ -63,6 +65,16 @@ public class MailProperties {
* */
private String isAuth = "true";

/**
* 重试间隔(单位:秒),默认为5秒
*/
private int retryInterval = 5;

/**
* 重试次数,默认为1次
*/
private int maxRetries = 1;

/**
* 多租户配置时需要配置此项,指定默认主租户
*/
Expand All @@ -73,4 +85,9 @@ public class MailProperties {
*/
private Map<String, MailSmtpConfig> tenant = Maps.newHashMap();

/**
* 黑名单
*/
private List<String> blacklist = Lists.newArrayList();

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.fxbin.bubble.core.util.CollectionUtils;
import cn.fxbin.bubble.mail.MailProperties;
import jakarta.annotation.Resource;
import org.dromara.email.api.Blacklist;
import org.dromara.email.api.MailClient;
import org.dromara.email.comm.config.MailSmtpConfig;
import org.dromara.email.core.factory.MailFactory;
Expand All @@ -14,6 +15,7 @@
import org.springframework.context.annotation.Lazy;
import org.springframework.util.Assert;

import java.util.List;
import java.util.Map;

/**
Expand Down Expand Up @@ -44,9 +46,11 @@ public MailClient mailClient() {
.fromAddress(properties.getFromAddress())
.isSSL(properties.getIsSsl())
.isAuth(properties.getIsAuth())
.maxRetries(properties.getMaxRetries())
.retryInterval(properties.getRetryInterval())
.build();
MailFactory.put("default", mailSmtpConfig);
return MailFactory.createMailClient("default");
return MailFactory.createMailClient("default", () -> properties.getBlacklist());
}

/**
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 2bd6355

Please sign in to comment.