From 559a6597977a42184015de369eb094cf9f846dad Mon Sep 17 00:00:00 2001 From: caiyuchao Date: Wed, 16 Apr 2025 16:16:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=82=AE=E4=BB=B6=E6=A0=87=E9=A2=98?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/properties/MailProperties.java | 5 ++ .../system/controller/SysEmailController.java | 7 +- .../src/main/resources/templates/mail.html | 68 ------------------- .../wfc/user/controller/UEmailController.java | 7 +- .../src/main/resources/templates/mail.html | 68 ------------------- 5 files changed, 17 insertions(+), 138 deletions(-) delete mode 100644 wfc-modules/wfc-system/src/main/resources/templates/mail.html delete mode 100644 wfc-modules/wfc-user/src/main/resources/templates/mail.html diff --git a/wfc-common/wfc-common-mail/src/main/java/org/wfc/common/mail/config/properties/MailProperties.java b/wfc-common/wfc-common-mail/src/main/java/org/wfc/common/mail/config/properties/MailProperties.java index 18c7848..ea313db 100644 --- a/wfc-common/wfc-common-mail/src/main/java/org/wfc/common/mail/config/properties/MailProperties.java +++ b/wfc-common/wfc-common-mail/src/main/java/org/wfc/common/mail/config/properties/MailProperties.java @@ -66,4 +66,9 @@ public class MailProperties { * Socket连接超时值,单位毫秒,缺省值不超时 */ private Long connectionTimeout; + + /** + * 邮件标题 + */ + private String subject; } diff --git a/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysEmailController.java b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysEmailController.java index d840012..93b8111 100644 --- a/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysEmailController.java +++ b/wfc-modules/wfc-system/src/main/java/org/wfc/system/controller/SysEmailController.java @@ -2,6 +2,7 @@ package org.wfc.system.controller; import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; @@ -56,7 +57,11 @@ public class SysEmailController extends BaseController { context.setVariable("verificationCode", code); context.setVariable("expirationTime", Constants.MAIL_CAPTCHA_EXPIRATION); String htmlStr = templateEngine.process("mail", context); - MailUtils.sendHtml(email, "Your WANFI verification code", htmlStr); + String subject = mailProperties.getSubject(); + if (StrUtil.isBlank(subject)) { + subject = "Your WANFI Verification Code"; + } + MailUtils.sendHtml(email, subject, htmlStr); } catch (Exception e) { log.error("email verification code send failed => {}", e.getMessage()); return R.fail(e.getMessage()); diff --git a/wfc-modules/wfc-system/src/main/resources/templates/mail.html b/wfc-modules/wfc-system/src/main/resources/templates/mail.html deleted file mode 100644 index 7d6e42f..0000000 --- a/wfc-modules/wfc-system/src/main/resources/templates/mail.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - 验证码邮件 - - - - - - - -
- - - - - - - - - - - - - - - - -
- 公司Logo -
-

您的验证码

-

- 请使用以下验证码完成操作: -

-
- -
- -

- 该验证码将在 分钟后失效,请及时使用 -

-
-

- 此为系统自动发送邮件,请勿直接回复
- 如有疑问请联系 support@example.com
- © 2023 您的公司名称。保留所有权利 -

-

- 退订邮件 -

-
- -
- - \ No newline at end of file diff --git a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UEmailController.java b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UEmailController.java index 94903c2..b47b1c4 100644 --- a/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UEmailController.java +++ b/wfc-modules/wfc-user/src/main/java/org/wfc/user/controller/UEmailController.java @@ -2,6 +2,7 @@ package org.wfc.user.controller; import cn.hutool.core.util.RandomUtil; +import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; @@ -56,7 +57,11 @@ public class UEmailController extends BaseController { context.setVariable("verificationCode", code); context.setVariable("expirationTime", Constants.MAIL_CAPTCHA_EXPIRATION); String htmlStr = templateEngine.process("mail", context); - MailUtils.sendHtml(email, "Your WANFI verification code", htmlStr); + String subject = mailProperties.getSubject(); + if (StrUtil.isBlank(subject)) { + subject = "Your WANFI Verification Code"; + } + MailUtils.sendHtml(email, subject, htmlStr); } catch (Exception e) { log.error("email verification code send failed => {}", e.getMessage()); return R.fail(e.getMessage()); diff --git a/wfc-modules/wfc-user/src/main/resources/templates/mail.html b/wfc-modules/wfc-user/src/main/resources/templates/mail.html deleted file mode 100644 index 7d6e42f..0000000 --- a/wfc-modules/wfc-user/src/main/resources/templates/mail.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - 验证码邮件 - - - - - - - -
- - - - - - - - - - - - - - - - -
- 公司Logo -
-

您的验证码

-

- 请使用以下验证码完成操作: -

-
- -
- -

- 该验证码将在 分钟后失效,请及时使用 -

-
-

- 此为系统自动发送邮件,请勿直接回复
- 如有疑问请联系 support@example.com
- © 2023 您的公司名称。保留所有权利 -

-

- 退订邮件 -

-
- -
- - \ No newline at end of file