From 32571c0990ae9b4a2d477ab0166a1a24d53bbf7f Mon Sep 17 00:00:00 2001 From: Zach Wasserman Date: Thu, 9 Dec 2021 09:58:33 -0800 Subject: [PATCH] Add wrap for SMTP connection error (#3206) --- server/mail/mail.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/mail/mail.go b/server/mail/mail.go index 06e9ae9595..4617e63005 100644 --- a/server/mail/mail.go +++ b/server/mail/mail.go @@ -151,7 +151,7 @@ func (m mailService) sendMail(e fleet.Email, msg []byte) error { if e.Config.SMTPSettings.SMTPAuthenticationMethod == fleet.AuthMethodNameCramMD5 { err = smtp.SendMail(smtpHost, auth, e.Config.SMTPSettings.SMTPSenderAddress, e.To, msg) if err != nil { - return fmt.Errorf("failed to send mail. cramd5 auth method: %w", err) + return fmt.Errorf("failed to send mail. crammd5 auth method: %w", err) } return nil } @@ -235,7 +235,7 @@ func dialTimeout(addr string) (client *smtp.Client, err error) { _ = conn.SetDeadline(time.Now().Add(28 * time.Second)) client, err = smtp.NewClient(conn, host) if err != nil { - return nil, errors.New("SMTP connection error") + return nil, fmt.Errorf("SMTP connection error: %w", err) } // Clear deadlines _ = conn.SetDeadline(time.Time{})