TASK:向全体用户发送邮件

This commit is contained in:
2026-03-31 15:43:11 +08:00
parent 379392c38d
commit 26d2d95acc

View File

@@ -1030,15 +1030,24 @@ public class SendEmailUtil {
private final static Long CN_2025_618 = 141425L; private final static Long CN_2025_618 = 141425L;
private final static Long EN_2025_618 = 141424L; private final static Long EN_2025_618 = 141424L;
public static void send618PromotionEmailTemp(String receiver, String language){
try { 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); Credential cred = new Credential(SECRET_ID, SECRET_KEy);
HttpProfile httpProfile = new HttpProfile(); HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("ses.tencentcloudapi.com"); httpProfile.setEndpoint("ses.tencentcloudapi.com");
ClientProfile clientProfile = new ClientProfile(); ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile); clientProfile.setHttpProfile(httpProfile);
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile); return new SesClient(cred, "ap-hongkong", clientProfile);
}
public static void send618PromotionEmailTemp(String receiver, String language){
SesClient client = null;
try {
client = getSesClient();
SendEmailRequest req = new SendEmailRequest(); SendEmailRequest req = new SendEmailRequest();
req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS); req.setFromEmailAddress(CODE_CREATE_SEND_ADDRESS);
req.setDestination(new String[]{receiver}); req.setDestination(new String[]{receiver});
@@ -1046,20 +1055,15 @@ public class SendEmailUtil {
// 根据邮件类型设置不同的主题和模板 // 根据邮件类型设置不同的主题和模板
String subject = ""; String subject = "";
Template template = new Template(); Template template = new Template();
// if (type == 1) { subject = "From Idea to Wow. \uD83D\uDD25 | AiDA Demo & Global Awards \n灵感开挂创作起飞 \uD83D\uDD25 | AiDA Demo & 全球设计大奖";
// subject = "Upcoming System Upgrade for AiDA 3.0"; template.setTemplateID(EN_GLOBAL_AWARDS);
// template.setTemplateID(UPGRADE_NOTIFICATION_ID); /*if (language.equals("ENGLISH")) {
// }else { subject = "From Idea to Wow. \uD83D\uDD25 | AiDA Demo & Global Awards";
// subject = "即将到来的AiDA 3.0系统升级"; template.setTemplateID(EN_GLOBAL_AWARDS);
// 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);
}else { }else {
subject = "设计时速狂飙AiDA 618半价让灵感永不限流"; subject = "灵感开挂,创作起飞 \uD83D\uDD25 | AiDA Demo & 全球设计大奖";
template.setTemplateID(CN_2025_618); template.setTemplateID(CN_GLOBAL_AWARDS);
} }*/
req.setSubject(subject); req.setSubject(subject);
req.setTemplate(template); req.setTemplate(template);
@@ -1069,9 +1073,7 @@ public class SendEmailUtil {
log.info("邮件发送成功,收件人地址:{}", receiver); log.info("邮件发送成功,收件人地址:{}", receiver);
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp)); log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) { } catch (TencentCloudSDKException e) {
log.info(receiver); log.error("邮件发送失败,收件人地址:{},错误信息:{}", receiver, e.toString());
log.error("邮件发送失败###{},收件人地址:{}", e.toString(), receiver);
} }
} }