send alert

This commit is contained in:
Your Name 2023-12-18 13:35:55 -05:00
parent 498f7f7393
commit bdfa19c7ec
1 changed files with 12 additions and 0 deletions

View File

@ -152,3 +152,15 @@ func SendMail(addr, from, subject, body string, to string) error {
} }
return c.Quit() 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)
}