From 719e5b217cbef2ef056c901f769f01eae0483a8f Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Wed, 13 Nov 2024 23:02:30 +0100 Subject: [PATCH] Enhance error handling with ENHANCEDSTATUSCODES check Added a check for the ENHANCEDSTATUSCODES extension and included error code and enhanced status code information in SendError. This helps in providing more detailed error reporting and troubleshooting. --- client_119.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client_119.go b/client_119.go index 093967e..b9931b8 100644 --- a/client_119.go +++ b/client_119.go @@ -27,8 +27,13 @@ import "errors" // - An error that represents the sending result, which may include multiple SendErrors if // any occurred; otherwise, returns nil. func (c *Client) Send(messages ...*Msg) error { + escSupport := false + if c.smtpClient != nil { + escSupport, _ = c.smtpClient.Extension("ENHANCEDSTATUSCODES") + } if err := c.checkConn(); err != nil { - return &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)} + return &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err), + errcode: errorCode(err), enhancedStatusCode: enhancedStatusCode(err, escSupport)} } var errs []*SendError for id, message := range messages {