diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/SystemParameterService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/SystemParameterService.java index 2cb12b588a..b19ad44ed9 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/SystemParameterService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/SystemParameterService.java @@ -125,10 +125,11 @@ public class SystemParameterService { } public void testConnection(HashMap hashMap) { - JavaMailSenderImpl javaMailSender = mailNoticeSender.getMailSender(hashMap); + JavaMailSenderImpl javaMailSender = null; try { + javaMailSender = mailNoticeSender.getMailSender(hashMap); javaMailSender.testConnection(); - } catch (MessagingException e) { + } catch (Exception e) { LogUtil.error(e.getMessage(), e); MSException.throwException(Translator.get("connection_failed")); } diff --git a/system-setting/frontend/src/business/system/setting/EmailSetting.vue b/system-setting/frontend/src/business/system/setting/EmailSetting.vue index 0a05442926..f1f7f7b203 100644 --- a/system-setting/frontend/src/business/system/setting/EmailSetting.vue +++ b/system-setting/frontend/src/business/system/setting/EmailSetting.vue @@ -89,6 +89,14 @@ import {getSystemMailServerInfo, modifySystemMailServerInfo, testMailServerConne export default { name: "EmailSetting", data() { + const validatorPortNum = (value, callback) => { + const numExp = /^[0-9]*$/ + if (!numExp.test(value)) { + callback(new Error("Port" + this.$t("commons.type_of_num"))) + }else{ + callback() + } + } return { formInline: {}, input: '', @@ -112,7 +120,10 @@ export default { { required: true, message: this.$t('system_parameter_setting.port'), - trigger: ['change', 'blur'] + trigger: ['change', 'blur'], + }, + { + validator: validatorPortNum, trigger: ['change', 'blur'], } ], account: [