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.
This commit is contained in:
Winni Neessen 2024-10-26 21:06:21 +02:00
parent f5279cd584
commit 42c63791ef
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -1261,14 +1261,13 @@ func (c *Client) sendSingleMsg(message *Msg) error {
affectedMsg: message, affectedMsg: message,
} }
} }
message.isDelivered = true
if err = writer.Close(); err != nil { if err = writer.Close(); err != nil {
return &SendError{ return &SendError{
Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err), Reason: ErrSMTPDataClose, errlist: []error{err}, isTemp: isTempError(err),
affectedMsg: message, affectedMsg: message,
} }
} }
message.isDelivered = true
if err = c.Reset(); err != nil { if err = c.Reset(); err != nil {
return &SendError{ return &SendError{