mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Mailgun: Support stored templates
Add support for Mailgun's new template option Fixes #155
This commit is contained in:
committed by
Mike Edmunds
parent
df3d577b41
commit
73a73ea01f
@@ -253,8 +253,8 @@ class MailgunPayload(RequestsPayload):
|
|||||||
def set_track_opens(self, track_opens):
|
def set_track_opens(self, track_opens):
|
||||||
self.data["o:tracking-opens"] = "yes" if track_opens else "no"
|
self.data["o:tracking-opens"] = "yes" if track_opens else "no"
|
||||||
|
|
||||||
# template_id: Mailgun doesn't offer stored templates.
|
def set_template_id(self, template_id):
|
||||||
# (The message body and other fields *are* the template content.)
|
self.data["template"] = template_id
|
||||||
|
|
||||||
def set_merge_data(self, merge_data):
|
def set_merge_data(self, merge_data):
|
||||||
# Processed at serialization time (to allow merging global data)
|
# Processed at serialization time (to allow merging global data)
|
||||||
|
|||||||
@@ -233,14 +233,10 @@ Limitations and quirks
|
|||||||
|
|
||||||
.. _mailgun-templates:
|
.. _mailgun-templates:
|
||||||
|
|
||||||
Batch sending/merge and ESP templates
|
Batch sending/merge
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
Mailgun does not offer :ref:`ESP stored templates <esp-stored-templates>`,
|
Mailgun supports :ref:`batch sending <batch-send>` with per-recipient
|
||||||
so Anymail's :attr:`~anymail.message.AnymailMessage.template_id` message
|
|
||||||
attribute is not supported with the Mailgun backend.
|
|
||||||
|
|
||||||
Mailgun *does* support :ref:`batch sending <batch-send>` with per-recipient
|
|
||||||
merge data. You can refer to Mailgun "recipient variables" in your
|
merge data. You can refer to Mailgun "recipient variables" in your
|
||||||
message subject and body, and supply the values with Anymail's
|
message subject and body, and supply the values with Anymail's
|
||||||
normalized :attr:`~anymail.message.AnymailMessage.merge_data`
|
normalized :attr:`~anymail.message.AnymailMessage.merge_data`
|
||||||
|
|||||||
@@ -448,7 +448,11 @@ class MailgunBackendAnymailFeatureTests(MailgunBackendMockAPITestCase):
|
|||||||
self.assertEqual(data['o:tracking-opens'], 'no')
|
self.assertEqual(data['o:tracking-opens'], 'no')
|
||||||
self.assertEqual(data['o:tracking-clicks'], 'yes')
|
self.assertEqual(data['o:tracking-clicks'], 'yes')
|
||||||
|
|
||||||
# template_id: Mailgun doesn't support stored templates
|
def test_template_id(self):
|
||||||
|
self.message.template_id = "welcome_template"
|
||||||
|
self.message.send()
|
||||||
|
data = self.get_api_call_data()
|
||||||
|
self.assertEqual(data['template'], "welcome_template")
|
||||||
|
|
||||||
def test_merge_data(self):
|
def test_merge_data(self):
|
||||||
self.message.to = ['alice@example.com', 'Bob <bob@example.com>']
|
self.message.to = ['alice@example.com', 'Bob <bob@example.com>']
|
||||||
|
|||||||
Reference in New Issue
Block a user