mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-07 10:16:21 +08:00
feat: Support configuration of SMTP username (#10636)
This commit is contained in:
parent
d2ecae7e97
commit
f71a8a1603
16 changed files with 37 additions and 2 deletions
|
|
@ -292,6 +292,7 @@ type AlertConfigTest struct {
|
|||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
Sender string `json:"sender"`
|
||||
UserName string `json:"userName"`
|
||||
Password string `json:"password"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Encryption string `json:"encryption"` // "ssl" / "tls" / "none"
|
||||
|
|
@ -323,6 +324,7 @@ type AlertEmailConfig struct {
|
|||
Host string `json:"host"`
|
||||
Port int `json:"port"`
|
||||
Sender string `json:"sender"`
|
||||
UserName string `json:"userName"`
|
||||
Password string `json:"password"`
|
||||
DisplayName string `json:"displayName"`
|
||||
Encryption string `json:"encryption"` // "ssl" / "tls" / "none"
|
||||
|
|
|
|||
|
|
@ -479,10 +479,14 @@ func (a AlertService) DeleteAlertConfig(id uint) error {
|
|||
}
|
||||
|
||||
func (a AlertService) TestAlertConfig(req dto.AlertConfigTest) (bool, error) {
|
||||
username := req.UserName
|
||||
if username == "" {
|
||||
username = req.Sender
|
||||
}
|
||||
cfg := email.SMTPConfig{
|
||||
Host: req.Host,
|
||||
Port: req.Port,
|
||||
Username: req.Sender,
|
||||
Username: username,
|
||||
Password: req.Password,
|
||||
From: fmt.Sprintf("%s <%s>", req.DisplayName, req.Sender),
|
||||
Encryption: req.Encryption,
|
||||
|
|
|
|||
|
|
@ -60,10 +60,14 @@ func CreateEmailAlertLog(create dto.AlertLogCreate, alert dto.AlertDTO, params [
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
username := emailInfo.UserName
|
||||
if username == "" {
|
||||
username = emailInfo.Sender
|
||||
}
|
||||
smtpConfig := email.SMTPConfig{
|
||||
Host: emailInfo.Host,
|
||||
Port: emailInfo.Port,
|
||||
Username: emailInfo.Sender,
|
||||
Username: username,
|
||||
Password: emailInfo.Password,
|
||||
From: fmt.Sprintf("%s <%s>", emailInfo.DisplayName, emailInfo.Sender),
|
||||
Encryption: emailInfo.Encryption,
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ export namespace Alert {
|
|||
port: number;
|
||||
host: string;
|
||||
sender: string;
|
||||
userName: string;
|
||||
password: string;
|
||||
displayName: string;
|
||||
encryption: string;
|
||||
|
|
|
|||
|
|
@ -3899,6 +3899,7 @@ const message = {
|
|||
licenseExceptionRule: 'License exception alert, sent {0} times per day',
|
||||
panelLoginRule: 'Panel login alert, sent {0} times per day',
|
||||
sshLoginRule: 'SSH login alert, sent {0} times per day',
|
||||
userNameHelper: 'Username is empty, the sender address will be used by default',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: 'Ling Xia Gold',
|
||||
|
|
|
|||
|
|
@ -3836,6 +3836,7 @@ const message = {
|
|||
licenseExceptionRule: 'Alerta de licencia anómala, {0} envíos/día',
|
||||
panelLoginRule: 'Alerta de login en panel, {0} envíos/día',
|
||||
sshLoginRule: 'Alerta de login SSH, {0} envíos/día',
|
||||
userNameHelper: 'El nombre de usuario está vacío, se usará la dirección del remitente por defecto',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: 'Ling Xia Gold',
|
||||
|
|
|
|||
|
|
@ -3779,6 +3779,7 @@ const message = {
|
|||
licenseExceptionRule: 'ライセンス異常アラートは、1日あたり{0}回送信',
|
||||
panelLoginRule: 'パネルログインアラートは、1日あたり{0}回送信',
|
||||
sshLoginRule: 'SSHログインアラートは、1日あたり{0}回送信',
|
||||
userNameHelper: 'ユーザー名が空の場合、送信者のアドレスがデフォルトで使用されます',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: '凌霞金',
|
||||
|
|
|
|||
|
|
@ -3709,6 +3709,7 @@ const message = {
|
|||
licenseExceptionRule: '라이선스 이상 알림은 하루 {0}회 전송',
|
||||
panelLoginRule: '패널 로그인 알림은 하루 {0}회 전송',
|
||||
sshLoginRule: 'SSH 로그인 알림은 하루 {0}회 전송',
|
||||
userNameHelper: '사용자 이름이 비어 있으면 기본적으로 발신자 주소가 사용됩니다',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: '링샤 골드',
|
||||
|
|
|
|||
|
|
@ -3857,6 +3857,7 @@ const message = {
|
|||
licenseExceptionRule: 'Amaran kerosakan lesen, dihantar {0} kali sehari',
|
||||
panelLoginRule: 'Amaran log masuk panel, dihantar {0} kali sehari',
|
||||
sshLoginRule: 'Amaran log masuk SSH, dihantar {0} kali sehari',
|
||||
userNameHelper: 'Nama pengguna kosong, alamat penghantar akan digunakan secara lalai',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: 'Ling Xia Emas',
|
||||
|
|
|
|||
|
|
@ -3875,6 +3875,7 @@ const message = {
|
|||
licenseExceptionRule: 'Alerta de exceção de licença, enviado {0} vezes por dia',
|
||||
panelLoginRule: 'Alerta de login no painel, enviado {0} vezes por dia',
|
||||
sshLoginRule: 'Alerta de login SSH, enviado {0} vezes por dia',
|
||||
userNameHelper: 'O nome de usuário está vazio, o endereço do remetente será usado por padrão',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: 'Ling Xia Gold',
|
||||
|
|
|
|||
|
|
@ -3870,6 +3870,7 @@ const message = {
|
|||
licenseExceptionRule: 'Оповещение о сбое лицензии, отправляется {0} раз в день',
|
||||
panelLoginRule: 'Оповещение о входе в панель, отправляется {0} раз в день',
|
||||
sshLoginRule: 'Оповещение о входе по SSH, отправляется {0} раз в день',
|
||||
userNameHelper: 'Имя пользователя не указано, по умолчанию будет использоваться адрес отправителя',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: 'Лин Ся Золотой',
|
||||
|
|
|
|||
|
|
@ -3945,6 +3945,7 @@ const message = {
|
|||
licenseExceptionRule: 'Lisans hatası uyarısı, günde {0} kez gönderilir',
|
||||
panelLoginRule: 'Panel girişi uyarısı, günde {0} kez gönderilir',
|
||||
sshLoginRule: 'SSH girişi uyarısı, günde {0} kez gönderilir',
|
||||
userNameHelper: 'Kullanıcı adı boşsa, varsayılan olarak gönderici adresi kullanılacaktır',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: 'Ling Xia Altın',
|
||||
|
|
|
|||
|
|
@ -3627,6 +3627,7 @@ const message = {
|
|||
licenseExceptionRule: '許可證異常告警,每天發送 {0} 次',
|
||||
panelLoginRule: '面板登入告警,每天發送 {0} 次',
|
||||
sshLoginRule: 'SSH 登入告警,每天發送 {0} 次',
|
||||
userNameHelper: '使用者名稱為空時,將預設使用寄件者地址',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: '凌霞金',
|
||||
|
|
|
|||
|
|
@ -3595,6 +3595,7 @@ const message = {
|
|||
licenseExceptionRule: '许可证异常告警,每天发送 {0} 次',
|
||||
panelLoginRule: '面板登录告警,每天发送 {0} 次',
|
||||
sshLoginRule: 'SSH 登录告警告警,每天发送 {0} 次',
|
||||
userNameHelper: '用户名为空会默认使用发件箱地址',
|
||||
},
|
||||
theme: {
|
||||
lingXiaGold: '凌霞金',
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@
|
|||
{{ $t('xpack.alert.senderHelper') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.login.username')" prop="userName">
|
||||
<el-input v-model.trim="form.config.userName" />
|
||||
<span class="input-help">
|
||||
{{ $t('xpack.alert.userNameHelper') }}
|
||||
</span>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('xpack.alert.password')" prop="password">
|
||||
<el-input v-model.trim="form.config.password" type="password" show-password />
|
||||
<span class="input-help">
|
||||
|
|
@ -103,6 +109,7 @@ interface Config {
|
|||
status: string;
|
||||
displayName: string;
|
||||
sender: string;
|
||||
userName: string;
|
||||
password: string;
|
||||
host: string;
|
||||
port: number;
|
||||
|
|
@ -122,6 +129,7 @@ const form = reactive({
|
|||
displayName: '',
|
||||
sender: '',
|
||||
password: '',
|
||||
userName: '',
|
||||
host: '',
|
||||
port: 465,
|
||||
encryption: 'NONE',
|
||||
|
|
@ -170,6 +178,7 @@ const onTest = async (formEl: FormInstance | undefined) => {
|
|||
if (!valid) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
debugger;
|
||||
await TestAlertConfig(form.config)
|
||||
.then((res) => {
|
||||
loading.value = false;
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@
|
|||
<el-form-item :label="$t('xpack.alert.sender')" prop="sender">
|
||||
{{ emailConfig.config.sender }}
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('commons.login.username')" prop="userName">
|
||||
{{ emailConfig.config.userName || emailConfig.config.sender }}
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('xpack.alert.host')" prop="host">
|
||||
{{ emailConfig.config.host }}
|
||||
</el-form-item>
|
||||
|
|
@ -186,6 +189,7 @@ export interface EmailConfig {
|
|||
config: {
|
||||
status?: string;
|
||||
sender?: string;
|
||||
userName?: string;
|
||||
password?: string;
|
||||
displayName?: string;
|
||||
host?: string;
|
||||
|
|
@ -202,6 +206,7 @@ const defaultEmailConfig: EmailConfig = {
|
|||
config: {
|
||||
displayName: '',
|
||||
sender: '',
|
||||
userName: '',
|
||||
password: '',
|
||||
host: '',
|
||||
port: 25,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue