refactor: 邮件配置匿名改成免密
This commit is contained in:
parent
a9ff93841b
commit
4a0c640aee
|
@ -95,8 +95,7 @@ public interface ParamConstants {
|
||||||
PASSWORD("smtp.password", 4),
|
PASSWORD("smtp.password", 4),
|
||||||
SSL("smtp.ssl", 5),
|
SSL("smtp.ssl", 5),
|
||||||
TLS("smtp.tls", 6),
|
TLS("smtp.tls", 6),
|
||||||
SMTP("smtp.smtp", 7);
|
ANON("smtp.anon", 7);
|
||||||
/* ANON("smtp.anon", 7);*/
|
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
private Integer value;
|
private Integer value;
|
||||||
|
|
|
@ -347,6 +347,7 @@ public class MailService {
|
||||||
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
|
List<SystemParameter> paramList = systemParameterService.getParamList(ParamConstants.Classify.MAIL.getValue());
|
||||||
javaMailSender.setDefaultEncoding("UTF-8");
|
javaMailSender.setDefaultEncoding("UTF-8");
|
||||||
javaMailSender.setProtocol("smtp");
|
javaMailSender.setProtocol("smtp");
|
||||||
|
props.put("mail.smtp.auth", "true");
|
||||||
|
|
||||||
for (SystemParameter p : paramList) {
|
for (SystemParameter p : paramList) {
|
||||||
switch (p.getParamKey()) {
|
switch (p.getParamKey()) {
|
||||||
|
@ -373,13 +374,19 @@ public class MailService {
|
||||||
props.put("mail.smtp.starttls.enable", result);
|
props.put("mail.smtp.starttls.enable", result);
|
||||||
props.put("mail.smtp.starttls.required", result);
|
props.put("mail.smtp.starttls.required", result);
|
||||||
break;
|
break;
|
||||||
|
case "smtp.anon":
|
||||||
|
boolean isAnon = BooleanUtils.toBoolean(p.getParamValue());
|
||||||
|
if (isAnon) {
|
||||||
|
props.put("mail.smtp.auth", "false");
|
||||||
|
javaMailSender.setUsername(null);
|
||||||
|
javaMailSender.setPassword(null);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
props.put("mail.smtp.auth", "true");
|
|
||||||
|
|
||||||
props.put("mail.smtp.timeout", "30000");
|
props.put("mail.smtp.timeout", "30000");
|
||||||
props.put("mail.smtp.connectiontimeout", "5000");
|
props.put("mail.smtp.connectiontimeout", "5000");
|
||||||
javaMailSender.setJavaMailProperties(props);
|
javaMailSender.setJavaMailProperties(props);
|
||||||
|
|
|
@ -86,7 +86,14 @@ public class SystemParameterService {
|
||||||
javaMailSender.setUsername(hashMap.get(ParamConstants.MAIL.ACCOUNT.getKey()));
|
javaMailSender.setUsername(hashMap.get(ParamConstants.MAIL.ACCOUNT.getKey()));
|
||||||
javaMailSender.setPassword(hashMap.get(ParamConstants.MAIL.PASSWORD.getKey()));
|
javaMailSender.setPassword(hashMap.get(ParamConstants.MAIL.PASSWORD.getKey()));
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put("mail.smtp.auth", "true");
|
boolean isAnon = Boolean.parseBoolean(hashMap.get(ParamConstants.MAIL.ANON.getKey()));
|
||||||
|
if (isAnon) {
|
||||||
|
props.put("mail.smtp.auth", "false");
|
||||||
|
javaMailSender.setUsername(null);
|
||||||
|
javaMailSender.setPassword(null);
|
||||||
|
} else {
|
||||||
|
props.put("mail.smtp.auth", "true");
|
||||||
|
}
|
||||||
if (BooleanUtils.toBoolean(hashMap.get(ParamConstants.MAIL.SSL.getKey()))) {
|
if (BooleanUtils.toBoolean(hashMap.get(ParamConstants.MAIL.SSL.getKey()))) {
|
||||||
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<el-checkbox v-model="formInline.TLS" :label="$t('system_parameter_setting.TLS')"></el-checkbox>
|
<el-checkbox v-model="formInline.TLS" :label="$t('system_parameter_setting.TLS')"></el-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div style="border: 0px;margin-bottom: 20px">
|
<div style="border: 0px;margin-bottom: 20px">
|
||||||
<el-checkbox v-model="formInline.SMTP" :label="$t('system_parameter_setting.SMTP')"></el-checkbox>
|
<el-checkbox v-model="formInline.ANON" :label="$t('system_parameter_setting.SMTP')"></el-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
</template>
|
</template>
|
||||||
|
@ -120,7 +120,7 @@ export default {
|
||||||
this.$set(this.formInline, "password", response.data[3].paramValue);
|
this.$set(this.formInline, "password", response.data[3].paramValue);
|
||||||
this.$set(this.formInline, "SSL", JSON.parse(response.data[4].paramValue));
|
this.$set(this.formInline, "SSL", JSON.parse(response.data[4].paramValue));
|
||||||
this.$set(this.formInline, "TLS", JSON.parse(response.data[5].paramValue));
|
this.$set(this.formInline, "TLS", JSON.parse(response.data[5].paramValue));
|
||||||
this.$set(this.formInline, "SMTP", JSON.parse(response.data[6].paramValue));
|
this.$set(this.formInline, "ANON", JSON.parse(response.data[6].paramValue));
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.formInline.clearValidate();
|
this.$refs.formInline.clearValidate();
|
||||||
})
|
})
|
||||||
|
@ -143,7 +143,7 @@ export default {
|
||||||
"smtp.password": this.formInline.password,
|
"smtp.password": this.formInline.password,
|
||||||
"smtp.ssl": this.formInline.SSL,
|
"smtp.ssl": this.formInline.SSL,
|
||||||
"smtp.tls": this.formInline.TLS,
|
"smtp.tls": this.formInline.TLS,
|
||||||
"smtp.smtp": this.formInline.SMTP,
|
"smtp.anon": this.formInline.ANON,
|
||||||
};
|
};
|
||||||
this.$refs[formInline].validate((valid) => {
|
this.$refs[formInline].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
@ -173,7 +173,7 @@ export default {
|
||||||
{paramKey: "smtp.password", paramValue: this.formInline.password, type: "password", sort: 4},
|
{paramKey: "smtp.password", paramValue: this.formInline.password, type: "password", sort: 4},
|
||||||
{paramKey: "smtp.ssl", paramValue: this.formInline.SSL, type: "text", sort: 5},
|
{paramKey: "smtp.ssl", paramValue: this.formInline.SSL, type: "text", sort: 5},
|
||||||
{paramKey: "smtp.tls", paramValue: this.formInline.TLS, type: "text", sort: 6},
|
{paramKey: "smtp.tls", paramValue: this.formInline.TLS, type: "text", sort: 6},
|
||||||
{paramKey: "smtp.smtp", paramValue: this.formInline.SMTP, type: "text", sort: 7}
|
{paramKey: "smtp.anon", paramValue: this.formInline.ANON, type: "text", sort: 7}
|
||||||
]
|
]
|
||||||
|
|
||||||
this.$refs[formInline].validate(valid => {
|
this.$refs[formInline].validate(valid => {
|
||||||
|
|
|
@ -1005,7 +1005,7 @@ export default {
|
||||||
SMTP_password: 'SMTP密码',
|
SMTP_password: 'SMTP密码',
|
||||||
SSL: '开启SSL(如果SMTP端口是465,通常需要启用SSL)',
|
SSL: '开启SSL(如果SMTP端口是465,通常需要启用SSL)',
|
||||||
TLS: '开启TLS(如果SMTP端口是587,通常需要启用TLS)',
|
TLS: '开启TLS(如果SMTP端口是587,通常需要启用TLS)',
|
||||||
SMTP: '是否匿名 SMTP',
|
SMTP: '是否免密 SMTP',
|
||||||
host: '主机号不能为空',
|
host: '主机号不能为空',
|
||||||
port: '端口号不能为空',
|
port: '端口号不能为空',
|
||||||
account: '账户不能为空',
|
account: '账户不能为空',
|
||||||
|
|
|
@ -1006,7 +1006,7 @@ export default {
|
||||||
SMTP_password: 'SMTP密碼',
|
SMTP_password: 'SMTP密碼',
|
||||||
SSL: '開啟SSL(如果SMTP端口是465,通常需要啟用SSL)',
|
SSL: '開啟SSL(如果SMTP端口是465,通常需要啟用SSL)',
|
||||||
TLS: '開啟TLS(如果SMTP端口是587,通常需要啟用TLS)',
|
TLS: '開啟TLS(如果SMTP端口是587,通常需要啟用TLS)',
|
||||||
SMTP: '是否匿名 SMTP',
|
SMTP: '是否免密 SMTP',
|
||||||
host: '主機號不能為空',
|
host: '主機號不能為空',
|
||||||
port: '端口號不能為空',
|
port: '端口號不能為空',
|
||||||
account: '賬戶不能為空',
|
account: '賬戶不能為空',
|
||||||
|
|
Loading…
Reference in New Issue