send alert
This commit is contained in:
parent
498f7f7393
commit
bdfa19c7ec
12
emails.go
12
emails.go
|
@ -152,3 +152,15 @@ func SendMail(addr, from, subject, body string, to string) error {
|
|||
}
|
||||
return c.Quit()
|
||||
}
|
||||
|
||||
func SendAlert(u int64, subject, body string) error {
|
||||
user, ok := GetById(u)
|
||||
if !ok {
|
||||
return fmt.Errorf("scsusers.SendAlert: User %d not found", u)
|
||||
}
|
||||
email, ok := user.Get("email")
|
||||
if !ok {
|
||||
return fmt.Errorf("scsusers.SendAlert: User %d has no email", u)
|
||||
}
|
||||
return SendMail(c.SMTPServer, c.FromEmail, subject, body, email)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue