http urls monitor.

12345678910111213141516171819202122232425262728
  1. package notice
  2. import (
  3. "net/smtp"
  4. "strings"
  5. "git.links123.net/links123.com/monitor_status/config"
  6. )
  7. func SendEmailBySMTP(subject, email, content string, html bool) error {
  8. user := config.C.Notice.SMTP.User
  9. host := config.C.Notice.SMTP.Host
  10. port := config.C.Notice.SMTP.Port
  11. pass := config.C.Notice.SMTP.Password
  12. auth := smtp.PlainAuth("", user, pass, host)
  13. contentType := "Content-Type:text/plain;charset=UTF-8"
  14. if html {
  15. contentType = "Content-Type:text/html;charset=UTF-8"
  16. }
  17. msg := []byte("To: " + email + "\r\nFrom: " + user + ">\r\nSubject: " + subject + "\r\n" + contentType + "\r\n\r\n" + content)
  18. to := strings.Split(email, ";")
  19. return smtp.SendMail(strings.Join([]string{host, port}, ":"), auth, user, to, msg)
  20. }