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.
This commit is contained in:
Winni Neessen 2022-12-31 12:46:11 +01:00
parent 47bff15de9
commit 88eb4c5663
Signed by: wneessen
GPG key ID: 385AC9889632126E
2 changed files with 2 additions and 0 deletions

View file

@ -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)

View file

@ -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)