mirror of https://gitee.com/xiaonuobase/snowy
【升级】邮件功能加入更多配置更通用
parent
c5d30b47d1
commit
a8d5405dec
|
@ -14,6 +14,28 @@
|
||||||
<a-form-item label="邮箱密钥:" name="SNOWY_EMAIL_LOCAL_PASSWORD">
|
<a-form-item label="邮箱密钥:" name="SNOWY_EMAIL_LOCAL_PASSWORD">
|
||||||
<a-input v-model:value="formData.SNOWY_EMAIL_LOCAL_PASSWORD" placeholder="请输入邮箱密钥" />
|
<a-input v-model:value="formData.SNOWY_EMAIL_LOCAL_PASSWORD" placeholder="请输入邮箱密钥" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
<a-form-item label="SMTP服务器域名:" name="SNOWY_EMAIL_LOCAL_SMTP_HOST">
|
||||||
|
<a-input v-model:value="formData.SNOWY_EMAIL_LOCAL_SMTP_HOST" placeholder="请输入SMTP服务器域名" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="SMTP服务端口:" name="SNOWY_EMAIL_LOCAL_SMTP_PORT">
|
||||||
|
<a-input-number
|
||||||
|
v-model:value="formData.SNOWY_EMAIL_LOCAL_SMTP_PORT"
|
||||||
|
placeholder="请输入SMTP服务端口"
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否需要用户名密码验证:" name="SNOWY_EMAIL_LOCAL_AUTH">
|
||||||
|
<a-switch v-model:checked="formData.SNOWY_EMAIL_LOCAL_AUTH" placeholder="请选择是否需要用户名密码验证" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否使用SSL安全连接:" name="SNOWY_EMAIL_LOCAL_SSL_ENABLE">
|
||||||
|
<a-switch v-model:checked="formData.SNOWY_EMAIL_LOCAL_SSL_ENABLE" placeholder="请选择是否使用SSL安全连接" />
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="是否使用STARTTLS安全连接:" name="SNOWY_EMAIL_LOCAL_STARTTLS_ENABLE">
|
||||||
|
<a-switch
|
||||||
|
v-model:checked="formData.SNOWY_EMAIL_LOCAL_STARTTLS_ENABLE"
|
||||||
|
placeholder="请选择是否使用STARTTLS安全连接"
|
||||||
|
/>
|
||||||
|
</a-form-item>
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
<a-button type="primary" :loading="submitLoading" @click="onSubmit()">保存</a-button>
|
<a-button type="primary" :loading="submitLoading" @click="onSubmit()">保存</a-button>
|
||||||
<a-button class="xn-ml10" @click="() => formRef.resetFields()">重置</a-button>
|
<a-button class="xn-ml10" @click="() => formRef.resetFields()">重置</a-button>
|
||||||
|
@ -41,13 +63,20 @@
|
||||||
loadSpinning.value = false
|
loadSpinning.value = false
|
||||||
if (data) {
|
if (data) {
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
formData.value[item.configKey] = item.configValue
|
formData.value[item.configKey] = transferBooleanInValue(item.configValue)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
message.warning('表单项不存在,请初始化数据库')
|
message.warning('表单项不存在,请初始化数据库')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 转换值
|
||||||
|
const transferBooleanInValue = (value) => {
|
||||||
|
if (value === 'true' || value === 'false') {
|
||||||
|
return value === 'true'
|
||||||
|
} else {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
// 默认要校验的
|
// 默认要校验的
|
||||||
const formRules = {
|
const formRules = {
|
||||||
SNOWY_EMAIL_LOCAL_FROM: [required('请输入发送邮箱号')],
|
SNOWY_EMAIL_LOCAL_FROM: [required('请输入发送邮箱号')],
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地邮件工具类
|
* 本地邮件工具类
|
||||||
|
@ -40,6 +41,16 @@ public class DevEmailLocalUtil {
|
||||||
private static final String SNOWY_EMAIL_LOCAL_FROM_KEY = "SNOWY_EMAIL_LOCAL_FROM";
|
private static final String SNOWY_EMAIL_LOCAL_FROM_KEY = "SNOWY_EMAIL_LOCAL_FROM";
|
||||||
private static final String SNOWY_EMAIL_LOCAL_PASSWORD_KEY = "SNOWY_EMAIL_LOCAL_PASSWORD";
|
private static final String SNOWY_EMAIL_LOCAL_PASSWORD_KEY = "SNOWY_EMAIL_LOCAL_PASSWORD";
|
||||||
|
|
||||||
|
private static final String SNOWY_EMAIL_LOCAL_SMTP_HOST_KEY = "SNOWY_EMAIL_LOCAL_SMTP_HOST";
|
||||||
|
|
||||||
|
private static final String SNOWY_EMAIL_LOCAL_SMTP_PORT_KEY = "SNOWY_EMAIL_LOCAL_SMTP_PORT";
|
||||||
|
|
||||||
|
private static final String SNOWY_EMAIL_LOCAL_AUTH_KEY = "SNOWY_EMAIL_LOCAL_AUTH";
|
||||||
|
|
||||||
|
private static final String SNOWY_EMAIL_LOCAL_SSL_ENABLE_KEY = "SNOWY_EMAIL_LOCAL_SSL_ENABLE";
|
||||||
|
|
||||||
|
private static final String SNOWY_EMAIL_LOCAL_STARTTLS_ENABLE_KEY = "SNOWY_EMAIL_LOCAL_STARTTLS_ENABLE";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化操作的客户端
|
* 初始化操作的客户端
|
||||||
*
|
*
|
||||||
|
@ -67,6 +78,28 @@ public class DevEmailLocalUtil {
|
||||||
mailAccount = new MailAccount();
|
mailAccount = new MailAccount();
|
||||||
mailAccount.setFrom(from);
|
mailAccount.setFrom(from);
|
||||||
mailAccount.setPass(pass);
|
mailAccount.setPass(pass);
|
||||||
|
|
||||||
|
/* SMTP服务器域名 */
|
||||||
|
String host = devConfigApi.getValueByKey(SNOWY_EMAIL_LOCAL_SMTP_HOST_KEY);
|
||||||
|
if (ObjectUtil.isNotEmpty(host)) {
|
||||||
|
mailAccount.setHost(host);
|
||||||
|
}
|
||||||
|
/* SMTP服务端口 */
|
||||||
|
String port = devConfigApi.getValueByKey(SNOWY_EMAIL_LOCAL_SMTP_PORT_KEY);
|
||||||
|
if (ObjectUtil.isNotEmpty(port)) {
|
||||||
|
mailAccount.setPort(Integer.parseInt(port));
|
||||||
|
}
|
||||||
|
/* 是否需要用户名密码验证 */
|
||||||
|
String auth = devConfigApi.getValueByKey(SNOWY_EMAIL_LOCAL_AUTH_KEY);
|
||||||
|
mailAccount.setAuth(Objects.equals(auth, "true"));
|
||||||
|
|
||||||
|
/* 是否使用SSL安全连接 */
|
||||||
|
String sslEnable = devConfigApi.getValueByKey(SNOWY_EMAIL_LOCAL_SSL_ENABLE_KEY);
|
||||||
|
mailAccount.setSslEnable(Objects.equals(sslEnable, "true"));
|
||||||
|
|
||||||
|
/* 是否使用STARTTLS安全连接 */
|
||||||
|
String starttlsEnable = devConfigApi.getValueByKey(SNOWY_EMAIL_LOCAL_STARTTLS_ENABLE_KEY);
|
||||||
|
mailAccount.setStarttlsEnable(Objects.equals(starttlsEnable, "true"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MailAccount getClient() {
|
public static MailAccount getClient() {
|
||||||
|
|
Loading…
Reference in New Issue