From 08ba7b656c967b1e4c1069e7bd7874ea1a88feae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 28 Nov 2024 14:47:11 +0100 Subject: [PATCH] Do not quit the SMTP sever on 421 error code smtplib is already closing the connection when such error code is received. Closes #13710 (grafted from e91426cb5d9db204250399823ab9e2acba640b1f) --HG-- branch : 7.0 --- trytond/trytond/sendmail.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trytond/trytond/sendmail.py b/trytond/trytond/sendmail.py index 43c66456af..bff52f7963 100644 --- a/trytond/trytond/sendmail.py +++ b/trytond/trytond/sendmail.py @@ -55,7 +55,8 @@ def sendmail(from_addr, to_addrs, msg, server=None, strict=False): logger.error('fail to send email', exc_info=True) except smtplib.SMTPResponseException as e: if count and 400 <= e.smtp_code <= 499 and hasattr(server, 'uri'): - server.quit() + if e.smtp_code != 421: + server.quit() server = get_smtp_server(server.uri, strict=strict) if server: continue