go-common/app/interface/main/laser/dao/email.go

20 lines
434 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package dao
import (
"go-common/library/log"
"gopkg.in/gomail.v2"
)
func (d *Dao) SendEmail(subject string, to string, body string) (err error) {
msg := gomail.NewMessage()
msg.SetHeader("From", d.c.Mail.Username)
msg.SetHeader("To", to)
msg.SetHeader("Subject", subject)
msg.SetBody("text/plain", body)
if err = d.email.DialAndSend(msg); err != nil {
log.Error("s.email.DialAndSend error(%v)", err)
return
}
return
}