diff options
author | George Goldberg <george@gberg.me> | 2017-08-25 11:04:37 +0100 |
---|---|---|
committer | Saturnino Abril <saturnino.abril@gmail.com> | 2017-08-25 18:04:37 +0800 |
commit | 1a2a02440c4e66d7f4869f3d24b4731c8df81fcf (patch) | |
tree | 452887dac94125b7b1152ced0f85ded11d9b092e /utils/mail.go | |
parent | f6e0310b502f5075659eb5a830d88e2026ee5f50 (diff) | |
download | chat-1a2a02440c4e66d7f4869f3d24b4731c8df81fcf.tar.gz chat-1a2a02440c4e66d7f4869f3d24b4731c8df81fcf.tar.bz2 chat-1a2a02440c4e66d7f4869f3d24b4731c8df81fcf.zip |
Other Packages: NewLocAppError -> NewAppError (#7283)
Diffstat (limited to 'utils/mail.go')
-rw-r--r-- | utils/mail.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/utils/mail.go b/utils/mail.go index 6e87e5731..b23e8c774 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -16,6 +16,7 @@ import ( l4g "github.com/alecthomas/log4go" "github.com/mattermost/html2text" "github.com/mattermost/platform/model" + "net/http" ) func encodeRFC2047Word(s string) string { @@ -34,12 +35,12 @@ func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) { conn, err = tls.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort, tlsconfig) if err != nil { - return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error()) + return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error(), http.StatusInternalServerError) } } else { conn, err = net.Dial("tcp", config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) if err != nil { - return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open.app_error", nil, err.Error()) + return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.open.app_error", nil, err.Error(), http.StatusInternalServerError) } } @@ -50,7 +51,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap c, err := smtp.NewClient(conn, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) if err != nil { l4g.Error(T("utils.mail.new_client.open.error"), err) - return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error()) + return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error(), http.StatusInternalServerError) } hostname := GetHostnameFromSiteURL(*config.ServiceSettings.SiteURL) @@ -58,7 +59,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap err := c.Hello(hostname) if err != nil { l4g.Error(T("utils.mail.new_client.helo.error"), err) - return nil, model.NewLocAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error()) + return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error(), http.StatusInternalServerError) } } @@ -74,7 +75,7 @@ func newSMTPClient(conn net.Conn, config *model.Config) (*smtp.Client, *model.Ap auth := smtp.PlainAuth("", config.EmailSettings.SMTPUsername, config.EmailSettings.SMTPPassword, config.EmailSettings.SMTPServer+":"+config.EmailSettings.SMTPPort) if err = c.Auth(auth); err != nil { - return nil, model.NewLocAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error()) + return nil, model.NewAppError("SendMail", "utils.mail.new_client.auth.app_error", nil, err.Error(), http.StatusInternalServerError) } } return c, nil @@ -148,25 +149,25 @@ func SendMailUsingConfig(to, subject, htmlBody string, config *model.Config) *mo defer c.Close() if err := c.Mail(fromMail.Address); err != nil { - return model.NewLocAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error()) + return model.NewAppError("SendMail", "utils.mail.send_mail.from_address.app_error", nil, err.Error(), http.StatusInternalServerError) } if err := c.Rcpt(to); err != nil { - return model.NewLocAppError("SendMail", "utils.mail.send_mail.to_address.app_error", nil, err.Error()) + return model.NewAppError("SendMail", "utils.mail.send_mail.to_address.app_error", nil, err.Error(), http.StatusInternalServerError) } w, err := c.Data() if err != nil { - return model.NewLocAppError("SendMail", "utils.mail.send_mail.msg_data.app_error", nil, err.Error()) + return model.NewAppError("SendMail", "utils.mail.send_mail.msg_data.app_error", nil, err.Error(), http.StatusInternalServerError) } _, err = m.WriteTo(w) if err != nil { - return model.NewLocAppError("SendMail", "utils.mail.send_mail.msg.app_error", nil, err.Error()) + return model.NewAppError("SendMail", "utils.mail.send_mail.msg.app_error", nil, err.Error(), http.StatusInternalServerError) } err = w.Close() if err != nil { - return model.NewLocAppError("SendMail", "utils.mail.send_mail.close.app_error", nil, err.Error()) + return model.NewAppError("SendMail", "utils.mail.send_mail.close.app_error", nil, err.Error(), http.StatusInternalServerError) } return nil |