From 7b63026610a758bfdd54d7bdbde0428c41f43bee Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 21 Oct 2025 16:24:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E4=B8=BB=E9=A2=98=E7=94=9F=E6=88=90=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=8C=85=E5=90=AB=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/notification/service/email.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modules/notification/service/email.go b/src/modules/notification/service/email.go index d9a42add..05b142ba 100644 --- a/src/modules/notification/service/email.go +++ b/src/modules/notification/service/email.go @@ -23,6 +23,7 @@ func EmailAlarm(a neDataModel.Alarm, neIP string) error { if len(emailList) == 0 { return fmt.Errorf("email list is empty") } + toEmailArr := strings.Split(emailList, ",") // 模板 htmlBodyTemplate := ` @@ -56,8 +57,15 @@ func EmailAlarm(a neDataModel.Alarm, neIP string) error { } htmlStr := buffer.String() + // 邮件标题 + subjectTitle := fmt.Sprintf("%s-%s-%s", a.OrigSeverity, a.NeName, a.AlarmTitle) + emailTitle := fmt.Sprint(config.Get("notification.email.title")) + if emailTitle != "" { + subjectTitle = fmt.Sprintf("%s-%s", emailTitle, subjectTitle) + } + // 发送邮件 - err = EmailSendHTML(htmlStr, strings.Split(emailList, ",")) + err = EmailSendHTML(subjectTitle, htmlStr, toEmailArr) if err != nil { return fmt.Errorf("EmailAlarm alarmId:%s fail %s", a.AlarmId, err.Error()) } @@ -65,7 +73,7 @@ func EmailAlarm(a neDataModel.Alarm, neIP string) error { } // EmailSendHTML 发送HTML邮件 -func EmailSendHTML(htmlStr string, toEmailArr []string) error { +func EmailSendHTML(title, htmlStr string, toEmailArr []string) error { // QQ 邮箱: // SMTP 服务器地址:smtp.qq.com(SSL协议端口:465/994 | 非SSL协议端口:25) // 163 邮箱: @@ -80,7 +88,6 @@ func EmailSendHTML(htmlStr string, toEmailArr []string) error { if !enable { return fmt.Errorf("email notification not enable") } - title := fmt.Sprint(emailConf["title"]) smtp := fmt.Sprint(emailConf["smtp"]) port := parse.Number(emailConf["port"]) user := fmt.Sprint(emailConf["user"])