Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions notify/mail_notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import (
)

type MailNotify struct {
Username string `json:"username"`
Password string `json:"password"`
Host string `json:"smtpHost"`
Port int `json:"port"`
From string `json:"from"`
To string `json:"to"`
Username string `json:"username"`
Password string `json:"password"`
Host string `json:"smtpHost"`
Port int `json:"port"`
From string `json:"from"`
To []string `json:"to"`
}

var (
Expand Down Expand Up @@ -57,12 +57,15 @@ func (mailNotify MailNotify) Initialize() error {
if err != nil {
return err
}
_, err = mail.ParseAddress(mailNotify.To)

//TODO: validate port and email host
if err != nil {
return err
}
for _, mailAddress := range mailNotify.To {
_, err = mail.ParseAddress(mailAddress)
if err != nil {
return err
}

}
return nil
}

Expand All @@ -79,7 +82,8 @@ func (mailNotify MailNotify) SendResponseTimeNotification(responseTimeNotificati
mailNotify.Host+":"+strconv.Itoa(mailNotify.Port),
auth,
mailNotify.From,
[]string{mailNotify.To},
//[]string{mailNotify.To},
mailNotify.To,
bytes.NewBufferString(message).Bytes(),
)

Expand Down Expand Up @@ -119,7 +123,8 @@ func (mailNotify MailNotify) SendErrorNotification(errorNotification ErrorNotifi
mailNotify.Host+":"+strconv.Itoa(mailNotify.Port),
auth,
mailNotify.From,
[]string{mailNotify.To},
//[]string{mailNotify.To},
mailNotify.To,
bytes.NewBufferString(message).Bytes(),
)
if err != nil {
Expand Down