Files
notify/email.go
2026-04-27 17:45:31 +03:00

32 lines
633 B
Go

package notify
import (
"errors"
"net/mail"
"net/smtp"
"github.com/scorredoira/email"
)
type SmtpAuth struct {
Addr string
Auth smtp.Auth
}
func SendEmailHTML(auth SmtpAuth, message, subject string, from mail.Address, to ...mail.Address) error {
if len(to) == 0 {
return errors.New("expected least one receiver")
}
mes := email.NewMessage(subject, message)
mes.BodyContentType = "text/html"
mes.From = from
for _, ito := range to {
mes.AddTo(ito)
}
return email.Send(auth.Addr, auth.Auth, mes)
}
func SenndEmailMessage(auth SmtpAuth, mes *email.Message) error {
return email.Send(auth.Addr, auth.Auth, mes)
}