Skip to content

Commit

Permalink
Move delivery status update after writer close check
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wneessen committed Oct 26, 2024
1 parent f5279cd commit 42c6379
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 42c6379

Please sign in to comment.