From 8838414c3814e7469907ae0ba137b4e0ffdf0020 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Tue, 1 Oct 2024 17:00:57 +0200 Subject: [PATCH] Fix incorrect error types for unsupported SMTP authentication Corrects the error messages returned for unsupported SMTP authentication types from ErrXOauth2AuthNotSupported to specific errors like ErrSCRAMSHA1AuthNotSupported, ErrSCRAMSHA256AuthNotSupported, and so on. This change improves the accuracy of error reporting for various SMTP authentication mechanisms. --- client.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index b692af3..acfeaa2 100644 --- a/client.go +++ b/client.go @@ -791,17 +791,17 @@ func (c *Client) auth() error { c.smtpAuth = smtp.XOAuth2Auth(c.user, c.pass) case SMTPAuthSCRAMSHA1: if !strings.Contains(smtpAuthType, string(SMTPAuthSCRAMSHA1)) { - return ErrXOauth2AuthNotSupported + return ErrSCRAMSHA1AuthNotSupported } c.smtpAuth = smtp.ScramSHA1Auth(c.user, c.pass) case SMTPAuthSCRAMSHA256: if !strings.Contains(smtpAuthType, string(SMTPAuthSCRAMSHA256)) { - return ErrXOauth2AuthNotSupported + return ErrSCRAMSHA256AuthNotSupported } c.smtpAuth = smtp.ScramSHA256Auth(c.user, c.pass) case SMTPAuthSCRAMSHA1PLUS: if !strings.Contains(smtpAuthType, string(SMTPAuthSCRAMSHA1PLUS)) { - return ErrXOauth2AuthNotSupported + return ErrSCRAMSHA1PLUSAuthNotSupported } tlsConnState, err := c.smtpClient.GetTLSConnectionState() if err != nil { @@ -810,7 +810,7 @@ func (c *Client) auth() error { c.smtpAuth = smtp.ScramSHA1PlusAuth(c.user, c.pass, tlsConnState) case SMTPAuthSCRAMSHA256PLUS: if !strings.Contains(smtpAuthType, string(SMTPAuthSCRAMSHA256PLUS)) { - return ErrXOauth2AuthNotSupported + return ErrSCRAMSHA256PLUSAuthNotSupported } tlsConnState, err := c.smtpClient.GetTLSConnectionState() if err != nil {