From ce81c30e3e7fd6228265cf0503f836121bb63999 Mon Sep 17 00:00:00 2001 From: Sergey Lavrinenko Date: Tue, 31 Mar 2026 01:16:17 +0300 Subject: [PATCH] Quit SMTP connection on any initialization failure Broaden the except clause from SMTPAuthenticationError to Exception so the connection is cleaned up when starttls() or ehlo_or_helo_if_needed() fails as well. Fixes #179 --- emails/backend/smtp/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emails/backend/smtp/client.py b/emails/backend/smtp/client.py index a15ee62..fb0b5cb 100644 --- a/emails/backend/smtp/client.py +++ b/emails/backend/smtp/client.py @@ -27,7 +27,7 @@ def __init__(self, parent, **kwargs): try: self.initialize() - except smtplib.SMTPAuthenticationError: + except Exception: self.quit() raise