From 42c63791ef2ac7f41e24975df9345e5bc458c5ba Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 26 Oct 2024 21:06:21 +0200 Subject: [PATCH] Move delivery status update after writer close check Relocated the `isDelivered` flag update to occur after the writer's close method validation. This ensures that the message delivery status is only marked as true if no errors arise during the writer close process. This showed up in the new test cases that covered errors on closing the DATA channel. This can already happen before the first byte is sent to the server. Therefore isDelivered should be set after a successful close. --- client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/client.go b/client.go index 50d2f28..abb90f4 100644 --- a/client.go +++ b/client.go @@ -1261,14 +1261,13 @@ func (c *Client) sendSingleMsg(message *Msg) error { affectedMsg: message, } } - message.isDelivered = true - if err = writer.Close(); err != nil { return &SendError{ Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err), affectedMsg: message, } } + message.isDelivered = true if err = c.Reset(); err != nil { return &SendError{