mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-21 21:30:50 +01:00
Enhance error handling in Client's Send method
Added support for Enhanced Status Codes (ESC) when checking the SMTP client's extensions. The SendError struct now includes the error code and enhanced status code for improved diagnostics.
This commit is contained in:
parent
a5ac7c3370
commit
c8d7cf86e1
1 changed files with 6 additions and 1 deletions
|
@ -27,8 +27,13 @@ import (
|
|||
// Returns:
|
||||
// - An error that aggregates any SendErrors encountered during the sending process; otherwise, returns nil.
|
||||
func (c *Client) Send(messages ...*Msg) (returnErr error) {
|
||||
escSupport := false
|
||||
if c.smtpClient != nil {
|
||||
escSupport, _ = c.smtpClient.Extension("ENHANCEDSTATUSCODES")
|
||||
}
|
||||
if err := c.checkConn(); err != nil {
|
||||
returnErr = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err)}
|
||||
returnErr = &SendError{Reason: ErrConnCheck, errlist: []error{err}, isTemp: isTempError(err),
|
||||
errcode: errorCode(err), enhancedStatusCode: enhancedStatusCode(err, escSupport)}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue