mail.go 752 B

12345678910111213141516171819202122232425
  1. /**
  2. #*****************************************************************************
  3. # @file mail.go
  4. # @author MakerYang(https://www.makeryang.com)
  5. # @statement 免费课程配套开源项目,任何形式收费均为盗版
  6. #*****************************************************************************
  7. */
  8. package Utils
  9. import "gopkg.in/gomail.v2"
  10. func SendMail(to string, subject string, content string) bool {
  11. status := true
  12. mail := gomail.NewMessage()
  13. mail.SetHeader("From", mail.FormatAddress("", ""))
  14. mail.SetHeader("To", to)
  15. mail.SetHeader("Subject", subject)
  16. mail.SetBody("text/html", content)
  17. send := gomail.NewDialer("smtp.qq.com", 587, "", "")
  18. if err := send.DialAndSend(mail); err != nil {
  19. status = false
  20. }
  21. return status
  22. }