Mailjet: Don't try to parse non-JSON responses as JSON.

Fixes #409.
This commit is contained in:
Mike Edmunds
2024-12-10 12:28:47 -08:00
parent c7f7428b7a
commit 8def0bdc06
3 changed files with 55 additions and 38 deletions

View File

@@ -34,7 +34,10 @@ class EmailBackend(AnymailRequestsBackend):
return MailjetPayload(message, defaults, self)
def raise_for_status(self, response, payload, message):
if 400 <= response.status_code <= 499:
content_type = (
response.headers.get("content-type", "").split(";")[0].strip().lower()
)
if 400 <= response.status_code <= 499 and content_type == "application/json":
# Mailjet uses 4xx status codes for partial failure in batch send;
# we'll determine how to handle below in parse_recipient_status.
return