Browse Source

fix:添加自定义邮箱发送

Roc 2 years ago
parent
commit
3d8e5536a7
2 changed files with 10 additions and 3 deletions
  1. 9 3
      controllers/alaram_msg.go
  2. 1 0
      models/alarm_msg.go

+ 9 - 3
controllers/alaram_msg.go

@@ -50,9 +50,15 @@ func (this *AlarmMsgController) SmsSend() {
 	//邮箱
 	{
 		if utils.RunMode == "release" {
-			configItem, _ := cache.GetSmsConfigByCache("email")
-			if configItem != nil {
-				go services.SendAlarmMsgByEmail(req.ProjectName, req.RunMode, req.MsgBody, configItem.ConfigValue, req.Level)
+			emailToUser := req.Email
+			if emailToUser == ``{
+				configItem, _ := cache.GetSmsConfigByCache("email")
+				if configItem != nil {
+					emailToUser = configItem.ConfigValue
+				}
+			}
+			if emailToUser != `nil` {
+				go services.SendAlarmMsgByEmail(req.ProjectName, req.RunMode, req.MsgBody, emailToUser, req.Level)
 			}
 		}
 	}

+ 1 - 0
models/alarm_msg.go

@@ -4,5 +4,6 @@ type AlarmMsgReq struct {
 	ProjectName string `description:"项目名称"`
 	RunMode     string `description:"运行模式"`
 	MsgBody     string `description:"消息内容"`
+	Email     	string `description:"指定邮箱"`
 	Level       int    `description:"消息级别,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息"`
 }