From 88eb4c56635cf56f83e43d0a13fd5cda86f1c58d Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 31 Dec 2022 12:46:11 +0100 Subject: [PATCH] I think it's fair that we reset the `Msg.senderror` to `nil` before we `Client.Send` it. Since the send error indicate an error during the mail delivery, in my opinion it should be reset when a re-send is initiated, so that the senderror field always represents the latest delivery error. The send error should be checked after mail delivery and before a retry is started. --- client_119.go | 1 + client_120.go | 1 + 2 files changed, 2 insertions(+) diff --git a/client_119.go b/client_119.go index ed27216..bcb8ec4 100644 --- a/client_119.go +++ b/client_119.go @@ -18,6 +18,7 @@ func (c *Client) Send(ml ...*Msg) error { return fmt.Errorf("failed to send mail: %w", err) } for _, m := range ml { + m.sendError = nil if m.encoding == NoEncoding { if ok, _ := c.sc.Extension("8BITMIME"); !ok { errs = append(errs, ErrServerNoUnencoded) diff --git a/client_120.go b/client_120.go index 568c21d..42b744d 100644 --- a/client_120.go +++ b/client_120.go @@ -19,6 +19,7 @@ func (c *Client) Send(ml ...*Msg) (rerr error) { return } for _, m := range ml { + m.sendError = nil if m.encoding == NoEncoding { if ok, _ := c.sc.Extension("8BITMIME"); !ok { rerr = errors.Join(rerr, ErrServerNoUnencoded)