Skip to content

Commit

Permalink
Email: Retry after weird microsoft failure
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Dec 5, 2023
1 parent 6fc76d4 commit 062395d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pretix/base/services/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 062395d

Please sign in to comment.