diff options
Diffstat (limited to 'utils/mail.go')
-rw-r--r-- | utils/mail.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/utils/mail.go b/utils/mail.go index ee5a8dd6f..119ca0674 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -6,6 +6,7 @@ package utils import ( "crypto/tls" "errors" + "fmt" "io" "mime" "net" @@ -17,8 +18,8 @@ import ( "net/http" - l4g "github.com/alecthomas/log4go" "github.com/mattermost/html2text" + "github.com/mattermost/mattermost-server/mlog" "github.com/mattermost/mattermost-server/model" ) @@ -128,14 +129,14 @@ func ConnectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) { func NewSMTPClientAdvanced(conn net.Conn, hostname string, connectionInfo *SmtpConnectionInfo) (*smtp.Client, *model.AppError) { c, err := smtp.NewClient(conn, connectionInfo.SmtpServerName+":"+connectionInfo.SmtpPort) if err != nil { - l4g.Error(T("utils.mail.new_client.open.error"), err) + mlog.Error(fmt.Sprintf("Failed to open a connection to SMTP server %v", err)) return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.open_tls.app_error", nil, err.Error(), http.StatusInternalServerError) } if hostname != "" { err := c.Hello(hostname) if err != nil { - l4g.Error(T("utils.mail.new_client.helo.error"), err) + mlog.Error(fmt.Sprintf("Failed to to set the HELO to SMTP server %v", err)) return nil, model.NewAppError("SendMail", "utils.mail.connect_smtp.helo.app_error", nil, err.Error(), http.StatusInternalServerError) } } @@ -180,14 +181,14 @@ func TestConnection(config *model.Config) { conn, err1 := ConnectToSMTPServer(config) if err1 != nil { - l4g.Error(T("utils.mail.test.configured.error"), T(err1.Message), err1.DetailedError) + mlog.Error(fmt.Sprintf("SMTP server settings do not appear to be configured properly err=%v details=%v", T(err1.Message), err1.DetailedError)) return } defer conn.Close() c, err2 := NewSMTPClient(conn, config) if err2 != nil { - l4g.Error(T("utils.mail.test.configured.error"), T(err2.Message), err2.DetailedError) + mlog.Error(fmt.Sprintf("SMTP server settings do not appear to be configured properly err=%v details=%v", T(err2.Message), err2.DetailedError)) return } defer c.Quit() @@ -228,13 +229,13 @@ func SendMailUsingConfigAdvanced(mimeTo, smtpTo string, from mail.Address, subje } func SendMail(c *smtp.Client, mimeTo, smtpTo string, from mail.Address, subject, htmlBody string, attachments []*model.FileInfo, mimeHeaders map[string]string, fileBackend FileBackend, date time.Time) *model.AppError { - l4g.Debug(T("utils.mail.send_mail.sending.debug"), mimeTo, subject) + mlog.Debug(fmt.Sprintf("sending mail to %v with subject of '%v'", mimeTo, subject)) htmlMessage := "\r\n<html><body>" + htmlBody + "</body></html>" txtBody, err := html2text.FromString(htmlBody) if err != nil { - l4g.Warn(err) + mlog.Warn(fmt.Sprint(err)) txtBody = "" } |