Files
notify/email.go
Vladimir V Maksimov 1d9d56dc87 telegram email
2025-12-10 17:14:16 +03:00

32 lines
634 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)
}