email.go 609 B

1234567891011121314151617181920212223
  1. package dao
  2. import (
  3. "go-common/app/service/main/account-recovery/conf"
  4. "go-common/library/log"
  5. "gopkg.in/gomail.v2"
  6. )
  7. // SendMail send the email.
  8. func (d *Dao) SendMail(body string, subject string, send ...string) (err error) {
  9. log.Info("send mail send:%v", send)
  10. msg := gomail.NewMessage()
  11. msg.SetHeader("From", conf.Conf.MailConf.Username)
  12. msg.SetHeader("To", send...)
  13. msg.SetHeader("Subject", subject)
  14. msg.SetBody("text/html", body, gomail.SetPartEncoding(gomail.Base64))
  15. if err = d.email.DialAndSend(msg); err != nil {
  16. log.Error("s.email.DialAndSend error(%v)", err)
  17. return
  18. }
  19. return
  20. }