refactor(common-mail): 使用 MailBuilder 替代 MailUtils

- 新增链式 MailBuilder,统一邮件发送入口
  - 删除 MailUtils,业务代码全部切换为 builder 调用
  - 默认邮件账户改为发送时获取,避免类加载阶段依赖 Bean
  - 自定义发件账号时复制默认配置,避免污染全局 MailAccount
  - 增加收件人、标题和正文参数校验
  - 调整内联图片流关闭时机,发送结束后统一关闭
  - 将 MailAccount 构建逻辑下沉到 MailProperties
This commit is contained in:
疯狂的狮子Li
2026-05-16 14:25:34 +08:00
parent f4b4c710c5
commit 99db6dceea
7 changed files with 382 additions and 494 deletions
@@ -11,7 +11,7 @@ import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.core.utils.StreamUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mail.utils.MailUtils;
import org.dromara.common.mail.core.MailBuilder;
import org.dromara.system.api.MessageService;
import org.dromara.system.api.domain.PushPayloadDTO;
import org.dromara.system.api.domain.UserDTO;
@@ -122,7 +122,7 @@ public class FlwCommonServiceImpl implements IFlwCommonService {
message, null, path
));
}
case EMAIL_MESSAGE -> MailUtils.sendText(emails, subject, message);
case EMAIL_MESSAGE -> MailBuilder.of().to(emails).subject(subject).text(message).send();
case SMS_MESSAGE -> {
// LinkedHashMap<String, String> map = new LinkedHashMap<>(1);
// // 根据具体短信服务商参数用法传参