mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Mailgun: handle x.y.z status code in webhooks
Mailgun sometimes (though not usually) gives the 'code' event field as an RFC-3463 extended SMTP status code. Handle either format. Fixes #62
This commit is contained in:
@@ -92,6 +92,15 @@ class MailgunTrackingWebhookView(MailgunBaseWebhookView):
|
||||
mta_status = int(esp_event['code'])
|
||||
except (KeyError, TypeError):
|
||||
pass
|
||||
except ValueError:
|
||||
# RFC-3463 extended SMTP status code (class.subject.detail, where class is "2", "4" or "5")
|
||||
try:
|
||||
status_class = esp_event['code'].split('.')[0]
|
||||
except (TypeError, IndexError):
|
||||
# illegal SMTP status code format
|
||||
pass
|
||||
else:
|
||||
reject_reason = RejectReason.BOUNCED if status_class in ("4", "5") else RejectReason.OTHER
|
||||
else:
|
||||
reject_reason = self.reject_reasons.get(
|
||||
mta_status,
|
||||
|
||||
Reference in New Issue
Block a user