mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Feature: Implement merge_headers
Implement and document `merge_headers` for all other ESPs that can support it. (See #371 for base and Amazon SES implementation.) Closes #374
This commit is contained in:
@@ -201,6 +201,36 @@ class MailgunBackendIntegrationTests(AnymailTestMixin, SimpleTestCase):
|
||||
# (We could try fetching the message from event["storage"]["url"]
|
||||
# to verify content and other headers.)
|
||||
|
||||
def test_per_recipient_options(self):
|
||||
message = AnymailMessage(
|
||||
from_email=formataddr(("Test From", self.from_email)),
|
||||
to=["test+to1@anymail.dev", '"Recipient 2" <test+to2@anymail.dev>'],
|
||||
subject="Anymail Mailgun per-recipient options test",
|
||||
body="This is the text body",
|
||||
merge_metadata={
|
||||
"test+to1@anymail.dev": {"meta1": "one", "meta2": "two"},
|
||||
"test+to2@anymail.dev": {"meta1": "recipient 2"},
|
||||
},
|
||||
headers={
|
||||
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
|
||||
"List-Unsubscribe": "<mailto:unsubscribe@example.com>",
|
||||
"X-Custom-Header": "default",
|
||||
},
|
||||
merge_headers={
|
||||
"test+to1@anymail.dev": {
|
||||
"List-Unsubscribe": "<https://example.com/a/>",
|
||||
"X-Custom-Header": "custom",
|
||||
},
|
||||
"test+to2@anymail.dev": {
|
||||
"List-Unsubscribe": "<https://example.com/b/>",
|
||||
},
|
||||
},
|
||||
)
|
||||
message.send()
|
||||
recipient_status = message.anymail_status.recipients
|
||||
self.assertEqual(recipient_status["test+to1@anymail.dev"].status, "queued")
|
||||
self.assertEqual(recipient_status["test+to2@anymail.dev"].status, "queued")
|
||||
|
||||
def test_stored_template(self):
|
||||
message = AnymailMessage(
|
||||
# name of a real template named in Anymail's Mailgun test account:
|
||||
|
||||
Reference in New Issue
Block a user