diff --git a/continew-admin-common/pom.xml b/continew-admin-common/pom.xml
index 026f3e08..90dcb9f1 100644
--- a/continew-admin-common/pom.xml
+++ b/continew-admin-common/pom.xml
@@ -34,6 +34,12 @@
continew-starter-data-mybatis-plus
+
+
+ top.charles7c.continew
+ continew-starter-messaging-mail
+
+
top.charles7c.continew
@@ -58,33 +64,28 @@
continew-starter-json-jackson
-
+
- org.springframework.boot
- spring-boot-starter-mail
+ org.dromara.sms4j
+ sms4j-spring-boot-starter
+
org.freemarker
freemarker
-
-
- org.springframework.boot
- spring-boot-starter-validation
-
-
com.mysql
mysql-connector-j
-
+
- org.dromara.sms4j
- sms4j-spring-boot-starter
+ org.springframework.boot
+ spring-boot-starter-validation
\ No newline at end of file
diff --git a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/MailUtils.java b/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/MailUtils.java
deleted file mode 100644
index 3a0ae8c5..00000000
--- a/continew-admin-common/src/main/java/top/charles7c/cnadmin/common/util/MailUtils.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package top.charles7c.cnadmin.common.util;
-
-import java.io.File;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import jakarta.mail.MessagingException;
-import jakarta.mail.internet.MimeMessage;
-
-import lombok.AccessLevel;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import org.springframework.mail.javamail.JavaMailSender;
-import org.springframework.mail.javamail.MimeMessageHelper;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.ArrayUtil;
-import cn.hutool.core.util.StrUtil;
-import cn.hutool.extra.spring.SpringUtil;
-
-import top.charles7c.cnadmin.common.util.validate.CheckUtils;
-import top.charles7c.continew.starter.core.constant.StringConstants;
-
-/**
- * 邮件工具类
- *
- * @author Charles7c
- * @since 2023/1/12 23:25
- */
-@Data
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public class MailUtils {
-
- private static final JavaMailSender MAIL_SENDER = SpringUtil.getBean(JavaMailSender.class);
-
- /**
- * 发送文本邮件给单个人
- *
- * @param subject
- * 主题
- * @param content
- * 内容
- * @param to
- * 收件人
- * @throws MessagingException
- * /
- */
- public static void sendText(String to, String subject, String content) throws MessagingException {
- send(splitAddress(to), null, null, subject, content, false);
- }
-
- /**
- * 发送 HTML 邮件给单个人
- *
- * @param subject
- * 主题
- * @param content
- * 内容
- * @param to
- * 收件人
- * @throws MessagingException
- * /
- */
- public static void sendHtml(String to, String subject, String content) throws MessagingException {
- send(splitAddress(to), null, null, subject, content, true);
- }
-
- /**
- * 发送 HTML 邮件给单个人
- *
- * @param subject
- * 主题
- * @param content
- * 内容
- * @param to
- * 收件人
- * @param files
- * 附件列表
- * @throws MessagingException
- * /
- */
- public static void sendHtml(String to, String subject, String content, File... files) throws MessagingException {
- send(splitAddress(to), null, null, subject, content, true, files);
- }
-
- /**
- * 发送 HTML 邮件给多个人
- *
- * @param subject
- * 主题
- * @param content
- * 内容
- * @param tos
- * 收件人列表
- * @param files
- * 附件列表
- * @throws MessagingException
- * /
- */
- public static void sendHtml(Collection tos, String subject, String content, File... files)
- throws MessagingException {
- send(tos, null, null, subject, content, true, files);
- }
-
- /**
- * 发送 HTML 邮件给多个人
- *
- * @param subject
- * 主题
- * @param content
- * 内容
- * @param tos
- * 收件人列表
- * @param ccs
- * 抄送人列表
- * @param files
- * 附件列表
- * @throws MessagingException
- * /
- */
- public static void sendHtml(Collection tos, Collection ccs, String subject, String content,
- File... files) throws MessagingException {
- send(tos, ccs, null, subject, content, true, files);
- }
-
- /**
- * 发送 HTML 邮件给多个人
- *
- * @param subject
- * 主题
- * @param content
- * 内容
- * @param tos
- * 收件人列表
- * @param ccs
- * 抄送人列表
- * @param bccs
- * 密送人列表
- * @param files
- * 附件列表
- * @throws MessagingException
- * /
- */
- public static void sendHtml(Collection tos, Collection ccs, Collection bccs, String subject,
- String content, File... files) throws MessagingException {
- send(tos, ccs, bccs, subject, content, true, files);
- }
-
- /**
- * 发送邮件给多个人
- *
- * @param tos
- * 收件人列表
- * @param ccs
- * 抄送人列表
- * @param bccs
- * 密送人列表
- * @param subject
- * 主题
- * @param content
- * 内容
- * @param isHtml
- * 是否是 HTML
- * @param files
- * 附件列表
- * @throws MessagingException
- * /
- */
- public static void send(Collection tos, Collection ccs, Collection bccs, String subject,
- String content, boolean isHtml, File... files) throws MessagingException {
- CheckUtils.throwIfEmpty(tos, "请至少指定一名收件人");
- MimeMessage mimeMessage = MAIL_SENDER.createMimeMessage();
- MimeMessageHelper messageHelper =
- new MimeMessageHelper(mimeMessage, true, StandardCharsets.UTF_8.displayName());
-
- // 设置基本信息
- messageHelper.setFrom(SpringUtil.getProperty("spring.mail.username"));
- messageHelper.setSubject(subject);
- messageHelper.setText(content, isHtml);
-
- // 设置收信人
- // 抄送人
- if (CollUtil.isNotEmpty(ccs)) {
- messageHelper.setCc(ccs.toArray(String[]::new));
- }
- // 密送人
- if (CollUtil.isNotEmpty(bccs)) {
- messageHelper.setBcc(bccs.toArray(String[]::new));
- }
- // 收件人
- messageHelper.setTo(tos.toArray(String[]::new));
-
- // 设置附件
- if (ArrayUtil.isNotEmpty(files)) {
- for (File file : files) {
- messageHelper.addAttachment(file.getName(), file);
- }
- }
-
- // 发送邮件
- MAIL_SENDER.send(mimeMessage);
- }
-
- /**
- * 将多个联系人转为列表,分隔符为逗号或者分号
- *
- * @param addresses
- * 多个联系人,如果为空返回null
- * @return 联系人列表
- */
- private static List splitAddress(String addresses) {
- if (StrUtil.isBlank(addresses)) {
- return new ArrayList<>(0);
- }
-
- List result;
- if (StrUtil.contains(addresses, StringConstants.COMMA)) {
- result = StrUtil.splitTrim(addresses, StringConstants.COMMA);
- } else if (StrUtil.contains(addresses, StringConstants.SEMICOLON)) {
- result = StrUtil.splitTrim(addresses, StringConstants.SEMICOLON);
- } else {
- result = CollUtil.newArrayList(addresses);
- }
- return result;
- }
-}
diff --git a/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/common/CaptchaController.java b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/common/CaptchaController.java
index b1fea832..fbe619c0 100644
--- a/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/common/CaptchaController.java
+++ b/continew-admin-webapi/src/main/java/top/charles7c/cnadmin/webapi/controller/common/CaptchaController.java
@@ -51,12 +51,12 @@ import top.charles7c.cnadmin.common.constant.CacheConstants;
import top.charles7c.cnadmin.common.constant.RegexConstants;
import top.charles7c.cnadmin.common.model.resp.CaptchaResp;
import top.charles7c.cnadmin.common.model.resp.R;
-import top.charles7c.cnadmin.common.util.MailUtils;
import top.charles7c.cnadmin.common.util.TemplateUtils;
import top.charles7c.cnadmin.common.util.validate.CheckUtils;
import top.charles7c.continew.starter.cache.redisson.util.RedisUtils;
import top.charles7c.continew.starter.captcha.graphic.autoconfigure.GraphicCaptchaProperties;
import top.charles7c.continew.starter.core.autoconfigure.project.ProjectProperties;
+import top.charles7c.continew.starter.messaging.mail.util.MailUtils;
/**
* 验证码 API
diff --git a/continew-admin-webapi/src/main/resources/config/application-dev.yml b/continew-admin-webapi/src/main/resources/config/application-dev.yml
index a2b6b84d..6c914846 100644
--- a/continew-admin-webapi/src/main/resources/config/application-dev.yml
+++ b/continew-admin-webapi/src/main/resources/config/application-dev.yml
@@ -136,7 +136,6 @@ spring.mail:
port: 465
username: 你的邮箱
password: 你的邮箱授权码
- default-encoding: utf-8
properties:
mail:
smtp:
diff --git a/continew-admin-webapi/src/main/resources/config/application-prod.yml b/continew-admin-webapi/src/main/resources/config/application-prod.yml
index 59edc988..a10d820c 100644
--- a/continew-admin-webapi/src/main/resources/config/application-prod.yml
+++ b/continew-admin-webapi/src/main/resources/config/application-prod.yml
@@ -138,7 +138,6 @@ spring.mail:
port: 465
username: 你的邮箱
password: 你的邮箱授权码
- default-encoding: utf-8
properties:
mail:
smtp: