telegram email
This commit is contained in:
31
email.go
Normal file
31
email.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user