Temporary email debugging.

This commit is contained in:
Azareal 2019-03-03 14:49:03 +10:00
parent 41e7464f8d
commit 3eb06d6822
1 changed files with 16 additions and 1 deletions

View File

@ -42,15 +42,18 @@ func SendEmail(email string, subject string, msg string) (err error) {
} }
conn, err := tls.Dial("tcp", Config.SMTPServer+":"+Config.SMTPPort, tlsconfig) conn, err := tls.Dial("tcp", Config.SMTPServer+":"+Config.SMTPPort, tlsconfig)
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
c, err = smtp.NewClient(conn, Config.SMTPServer) c, err = smtp.NewClient(conn, Config.SMTPServer)
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
} else { } else {
c, err = smtp.Dial(Config.SMTPServer + ":" + Config.SMTPPort) c, err = smtp.Dial(Config.SMTPServer + ":" + Config.SMTPPort)
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
} }
@ -59,31 +62,43 @@ func SendEmail(email string, subject string, msg string) (err error) {
auth := smtp.PlainAuth("", Config.SMTPUsername, Config.SMTPPassword, Config.SMTPServer) auth := smtp.PlainAuth("", Config.SMTPUsername, Config.SMTPPassword, Config.SMTPServer)
err = c.Auth(auth) err = c.Auth(auth)
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
} }
err = c.Mail(Site.Email) err = c.Mail(Site.Email)
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
err = c.Rcpt(email) err = c.Rcpt(email)
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
w, err := c.Data() w, err := c.Data()
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
_, err = w.Write([]byte(body)) _, err = w.Write([]byte(body))
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
err = w.Close() err = w.Close()
if err != nil { if err != nil {
LogWarning(err)
return err return err
} }
return c.Quit() err = c.Quit()
if err != nil {
LogWarning(err)
return err
}
return nil
} }