From 062395dac185bf24e1446ce04b034b2603c02ff7 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Tue, 5 Dec 2023 17:20:35 +0100 Subject: [PATCH] Email: Retry after weird microsoft failure --- src/pretix/base/services/mail.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pretix/base/services/mail.py b/src/pretix/base/services/mail.py index ffb7ce1046..733ac81f32 100644 --- a/src/pretix/base/services/mail.py +++ b/src/pretix/base/services/mail.py @@ -573,8 +573,11 @@ def mail_send_task(self, *args, to: List[str], subject: str, body: str, html: st except smtplib.SMTPRecipientsRefused as e: smtp_codes = [a[0] for a in e.recipients.values()] - if not any(c >= 500 for c in smtp_codes): - # Not a permanent failure (mailbox full, service unavailable), retry later, but with large intervals + if not any(c >= 500 for c in smtp_codes) or any(b'Message is too large' in a[1] for a in e.recipients.values()): + # This is not a permanent failure (mailbox full, service unavailable), retry later, but with large + # intervals. One would think that "Message is too lage" is a permanent failure, but apparently it is not. + # We have documented cases of emails to Microsoft returning the error occasionally and then later + # allowing the very same email. try: self.retry(max_retries=5, countdown=[60, 300, 600, 1200, 1800, 1800][self.request.retries]) except MaxRetriesExceededError: