From eba91d88d2891b539c794b7103be0453c5491959 Mon Sep 17 00:00:00 2001 From: wenyann <64353056+wenyann@users.noreply.github.com> Date: Fri, 13 Nov 2020 17:06:40 +0800 Subject: [PATCH] fix: i18n --- .../metersphere/notice/service/MailService.java | 17 +++++++++++------ .../resources/i18n/messages_en_US.properties | 4 ++-- .../resources/i18n/messages_zh_CN.properties | 4 ++-- .../resources/i18n/messages_zh_TW.properties | 4 ++-- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/metersphere/notice/service/MailService.java b/backend/src/main/java/io/metersphere/notice/service/MailService.java index 14479ce941..0cc1c5e44e 100644 --- a/backend/src/main/java/io/metersphere/notice/service/MailService.java +++ b/backend/src/main/java/io/metersphere/notice/service/MailService.java @@ -24,6 +24,7 @@ import org.apache.commons.collections4.MapUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RegExUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.mail.MailException; import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.stereotype.Service; @@ -99,10 +100,10 @@ public class MailService { MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true); helper.setFrom(javaMailSender.getUsername()); if (StringUtils.equals(type, NoticeConstants.API)) { - helper.setSubject("MeterSphere平台" + Translator.get("task_notification")); + helper.setSubject("MeterSphere平台" + Translator.get("task_notification_jenkins")); } if (StringUtils.equals(type, NoticeConstants.SCHEDULE)) { - helper.setSubject("MeterSphere平台" + Translator.get("task_notification_")); + helper.setSubject("MeterSphere平台" + Translator.get("task_notification")); } String[] users; List emails = new ArrayList<>(); @@ -113,7 +114,11 @@ public class MailService { users = emails.toArray(new String[0]); helper.setText(getContent(Template, context), true); helper.setTo(users); - javaMailSender.send(mimeMessage); + try { + javaMailSender.send(mimeMessage); + } catch (MailException e) { + LogUtil.error(e); + } } //测试评审 @@ -341,7 +346,7 @@ public class MailService { JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl(); List paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue()); javaMailSender.setDefaultEncoding("UTF-8"); - javaMailSender.setProtocol("smtp"); + javaMailSender.setProtocol("smtps"); for (SystemParameter p : paramList) { switch (p.getParamKey()) { case "smtp.host": @@ -362,8 +367,8 @@ public class MailService { } Properties props = new Properties(); props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.starttls.enable", "false"); - props.put("mail.smtp.starttls.required", "false"); + props.put("mail.smtp.starttls.enable", "true"); + props.put("mail.smtp.starttls.required", "true"); props.put("mail.smtp.timeout", "30000"); props.put("mail.smtp.connectiontimeout", "5000"); javaMailSender.setJavaMailProperties(props); diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index ea9fe501cc..76724a4100 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -167,8 +167,8 @@ check_owner_comment=The current user does not have permission to manipulate this upload_content_is_null=Imported content is empty test_plan_notification=Test plan notification task_defect_notification=Task defect notification -task_notification=Jenkins Task notification -task_notification_=Timing task result notification +task_notification_jenkins=Jenkins Task notification +task_notification=Result notification diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index 7745c3acd2..3d87761b8d 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -168,5 +168,5 @@ check_owner_comment=当前用户没有操作此评论的权限 upload_content_is_null=导入内容为空 test_plan_notification=测试计划通知 task_defect_notification=缺陷任务通知 -task_notification=jenkins任务通知 -task_notification_=定时任务结果通知 \ No newline at end of file +task_notification_jenkins=jenkins任务通知 +task_notification=任务通知 \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 32411f615d..597db40028 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -169,6 +169,6 @@ check_owner_comment=當前用戶沒有操作此評論的權限 upload_content_is_null=導入內容為空 test_plan_notification=測試計畫通知 task_defect_notification=缺陷任務通知 -task_notification=jenkins任務通知 -task_notification_=定時任務通知 +task_notification_jenkins=jenkins任務通知 +task_notification=任務通知