设备监控状态异常邮箱修改成配置文件读取

This commit is contained in:
junleea 2025-09-03 20:38:06 +08:00
parent 4592681978
commit 6e5ee4f0e2
2 changed files with 33 additions and 22 deletions

View File

@ -440,7 +440,14 @@ func SendMail(title, content string) {
em.SmtpUserName = "354425203@qq.com" em.SmtpUserName = "354425203@qq.com"
em.SmtpPort = 587 em.SmtpPort = 587
em.ImapPort = 993 em.ImapPort = 993
err := em.Send(title, content, []string{"3236990479@qq.com", "lijun@ljsea.top"}) var targetMails []string
for _, v := proto.Config.MONITOR_MAIL{
targetMails = append(targetMails, v.Value)
}
if targetMails == nil || len(targetMails) == 0 {
return
}
err := em.Send(title, content, targetMails)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} }

View File

@ -73,6 +73,9 @@ type User struct {
Email string `gorm:"column:email"` Email string `gorm:"column:email"`
Gender string `gorm:"column:gender"` Gender string `gorm:"column:gender"`
} }
type StructValue struct {
Value string `json:"value" form:"value"`
}
type ConfigStruct struct { type ConfigStruct struct {
DB int `json:"db"` // 0: mysql, 1: pg DB int `json:"db"` // 0: mysql, 1: pg
@ -96,6 +99,7 @@ type ConfigStruct struct {
SERVER_NAME string `json:"server_name"` // 服务器名称,用于区分不同服务器 SERVER_NAME string `json:"server_name"` // 服务器名称,用于区分不同服务器
MONITOR_SERVER_TOKEN string `json:"monitor_server_token"` // 监控服务器token,用于状态监控及邮件通知 MONITOR_SERVER_TOKEN string `json:"monitor_server_token"` // 监控服务器token,用于状态监控及邮件通知
APP_ID string `json:"app_id"` // 应用ID,用于标识不同应用 APP_ID string `json:"app_id"` // 应用ID,用于标识不同应用
MONITOR_MAIL []StructValue `json:"monitor_mail"` // 设备监控邮件通知配置
} }
func WriteConfigToFile() { func WriteConfigToFile() {