telegram email

This commit is contained in:
Vladimir V Maksimov
2025-12-10 17:14:16 +03:00
parent b20e040fae
commit 1d9d56dc87
5 changed files with 156 additions and 4 deletions

31
email.go Normal file
View File

@@ -0,0 +1,31 @@
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)
}