diff --git a/emails.go b/emails.go index 0f92571..efd9d1c 100644 --- a/emails.go +++ b/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) +}