Skip to content

Quit SMTP connection on failed login#173

Merged
lavr merged 1 commit intolavr:masterfrom
codeZeilen:quit-connection-on-failed-login
Mar 30, 2026
Merged

Quit SMTP connection on failed login#173
lavr merged 1 commit intolavr:masterfrom
codeZeilen:quit-connection-on-failed-login

Conversation

@codeZeilen
Copy link
Copy Markdown
Contributor

@codeZeilen codeZeilen commented Apr 24, 2025

This is a slight improvement to the SMTPClient. Currently the client does not gracefully quit the connection when authentication fails. While the socket is eventually closed on GC, this could be done earlier by explicitly quitting.

(Found while testing python-emails in RosettaTest)

@lavr
Copy link
Copy Markdown
Owner

lavr commented Mar 30, 2026

Thanks for the PR! The change makes sense — no reason to leave the connection open when authentication fails.

One thought: since initialize() can also fail on starttls() or ehlo_or_helo_if_needed(), it might be worth catching Exception instead of just SMTPAuthenticationError to clean up the connection on any initialization failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants