From 26d2d95acc4d5ab519bdf6d938682f97791ce03b Mon Sep 17 00:00:00 2001 From: xupei Date: Tue, 31 Mar 2026 15:43:11 +0800 Subject: [PATCH] =?UTF-8?q?TASK:=E5=90=91=E5=85=A8=E4=BD=93=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ai/da/common/utils/SendEmailUtil.java | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java index 2d7a9e74..160ee4e2 100644 --- a/src/main/java/com/ai/da/common/utils/SendEmailUtil.java +++ b/src/main/java/com/ai/da/common/utils/SendEmailUtil.java @@ -1030,15 +1030,24 @@ public class SendEmailUtil { private final static Long CN_2025_618 = 141425L; private final static Long EN_2025_618 = 141424L; + + private final static Long CN_GLOBAL_AWARDS = 166716L; + private final static Long EN_GLOBAL_AWARDS = 166715L; + + // 复用 SesClient,避免每次发送都创建新连接 + private static SesClient getSesClient() { + Credential cred = new Credential(SECRET_ID, SECRET_KEy); + HttpProfile httpProfile = new HttpProfile(); + httpProfile.setEndpoint("ses.tencentcloudapi.com"); + ClientProfile clientProfile = new ClientProfile(); + clientProfile.setHttpProfile(httpProfile); + return new SesClient(cred, "ap-hongkong", clientProfile); + } + public static void send618PromotionEmailTemp(String receiver, String language){ + SesClient client = null; try { - // 实例化一个认证对象 - Credential cred = new Credential(SECRET_ID, SECRET_KEy); - HttpProfile httpProfile = new HttpProfile(); - httpProfile.setEndpoint("ses.tencentcloudapi.com"); - ClientProfile clientProfile = new ClientProfile(); - clientProfile.setHttpProfile(httpProfile); - SesClient client = new SesClient(cred, "ap-hongkong", clientProfile); + client = getSesClient(); SendEmailRequest req = new SendEmailRequest(); req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS); req.setDestination(new String[]{receiver}); @@ -1046,20 +1055,15 @@ public class SendEmailUtil { // 根据邮件类型设置不同的主题和模板 String subject = ""; Template template = new Template(); -// if (type == 1) { -// subject = "Upcoming System Upgrade for AiDA 3.0"; -// template.setTemplateID(UPGRADE_NOTIFICATION_ID); -// }else { -// subject = "即将到来的AiDA 3.0系统升级"; -// template.setTemplateID(UPGRADE_NOTIFICATION_ID_CHINESE); -// } - if (language.equals("ENGLISH")) { - subject = "Welcome back !Subscribe AiDA with the discount code to enjoy 50% OFF!"; - template.setTemplateID(EN_2025_618); + subject = "From Idea to Wow. \uD83D\uDD25 | AiDA Demo & Global Awards \n灵感开挂,创作起飞 \uD83D\uDD25 | AiDA Demo & 全球设计大奖"; + template.setTemplateID(EN_GLOBAL_AWARDS); + /*if (language.equals("ENGLISH")) { + subject = "From Idea to Wow. \uD83D\uDD25 | AiDA Demo & Global Awards"; + template.setTemplateID(EN_GLOBAL_AWARDS); }else { - subject = "设计时速狂飙!AiDA 618半价让灵感永不限流!"; - template.setTemplateID(CN_2025_618); - } + subject = "灵感开挂,创作起飞 \uD83D\uDD25 | AiDA Demo & 全球设计大奖"; + template.setTemplateID(CN_GLOBAL_AWARDS); + }*/ req.setSubject(subject); req.setTemplate(template); @@ -1069,9 +1073,7 @@ public class SendEmailUtil { log.info("邮件发送成功,收件人地址:{}", receiver); log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp)); } catch (TencentCloudSDKException e) { - log.info(receiver); - log.error("邮件发送失败###{},收件人地址:{}", e.toString(), receiver); - + log.error("邮件发送失败,收件人地址:{},错误信息:{}", receiver, e.toString()); } }