Skip to content

Conversation

dannykopping
Copy link
Contributor

Follow up of #14495

If we don't call message.Close() once the method exits, we could leak resources.
This restores the defer, but conditionalizes it such that it will only call Close() if it hasn't already been called. If we don't do this, the SMTP lib will send a subsequent line to the server after an error response, which is invalid. It's not a trainsmash, but it's better to be defensive.

.                                            <--- initial Close()
501 5.5.4 Rejected!
.                                            <--- deferred Close()
501 5.5.2 Bad command

Signed-off-by: Danny Kopping <danny@coder.com>
Signed-off-by: Danny Kopping <danny@coder.com>
@dannykopping dannykopping merged commit 0f414a0 into main Aug 30, 2024
27 checks passed
@dannykopping dannykopping deleted the dk/smtp-close-fix branch August 30, 2024 11:03
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants