Add Mandrill send options auto_html, tracking_domain, signing_domain

This commit is contained in:
medmunds
2013-03-27 11:04:02 -07:00
parent ab1de7be2a
commit 717e048365
4 changed files with 37 additions and 1 deletions

View File

@@ -145,7 +145,9 @@ class DjrillBackend(BaseEmailBackend):
# Mandrill attributes that can be copied directly: # Mandrill attributes that can be copied directly:
mandrill_attrs = [ mandrill_attrs = [
'from_name', # overrides display name parsed from from_email above 'from_name', # overrides display name parsed from from_email above
'track_opens', 'track_clicks', 'auto_text', 'inline_css', 'url_strip_qs', 'track_opens', 'track_clicks', 'auto_text', 'auto_html',
'inline_css', 'url_strip_qs',
'tracking_domain', 'signing_domain',
'tags', 'preserve_recipients', 'tags', 'preserve_recipients',
'google_analytics_domains', 'google_analytics_campaign', 'google_analytics_domains', 'google_analytics_campaign',
'metadata'] 'metadata']

View File

@@ -296,13 +296,19 @@ class DjrillMandrillFeatureTests(DjrillBackendMockAPITestCase):
def test_message_options(self): def test_message_options(self):
self.message.auto_text = True self.message.auto_text = True
self.message.auto_html = True
self.message.inline_css = True self.message.inline_css = True
self.message.preserve_recipients = True self.message.preserve_recipients = True
self.message.tracking_domain = "click.example.com"
self.message.signing_domain = "example.com"
self.message.send() self.message.send()
data = self.get_api_call_data() data = self.get_api_call_data()
self.assertEqual(data['message']['auto_text'], True) self.assertEqual(data['message']['auto_text'], True)
self.assertEqual(data['message']['auto_html'], True)
self.assertEqual(data['message']['inline_css'], True) self.assertEqual(data['message']['inline_css'], True)
self.assertEqual(data['message']['preserve_recipients'], True) self.assertEqual(data['message']['preserve_recipients'], True)
self.assertEqual(data['message']['tracking_domain'], "click.example.com")
self.assertEqual(data['message']['signing_domain'], "example.com")
def test_merge(self): def test_merge(self):
# Djrill expands simple python dicts into the more-verbose name/content # Djrill expands simple python dicts into the more-verbose name/content
@@ -377,10 +383,13 @@ class DjrillMandrillFeatureTests(DjrillBackendMockAPITestCase):
self.assertFalse('track_opens' in data['message']) self.assertFalse('track_opens' in data['message'])
self.assertFalse('track_clicks' in data['message']) self.assertFalse('track_clicks' in data['message'])
self.assertFalse('auto_text' in data['message']) self.assertFalse('auto_text' in data['message'])
self.assertFalse('auto_html' in data['message'])
self.assertFalse('inline_css' in data['message']) self.assertFalse('inline_css' in data['message'])
self.assertFalse('url_strip_qs' in data['message']) self.assertFalse('url_strip_qs' in data['message'])
self.assertFalse('tags' in data['message']) self.assertFalse('tags' in data['message'])
self.assertFalse('preserve_recipients' in data['message']) self.assertFalse('preserve_recipients' in data['message'])
self.assertFalse('tracking_domain' in data['message'])
self.assertFalse('signing_domain' in data['message'])
self.assertFalse('google_analytics_domains' in data['message']) self.assertFalse('google_analytics_domains' in data['message'])
self.assertFalse('google_analytics_campaign' in data['message']) self.assertFalse('google_analytics_campaign' in data['message'])
self.assertFalse('metadata' in data['message']) self.assertFalse('metadata' in data['message'])

View File

@@ -1,6 +1,12 @@
Release Notes Release Notes
============= =============
Version 0.5 (development):
* Support for Mandrill send options :attr:`auto_html`, :attr:`tracking_domain`
and :attr:`signing_domain`.
Version 0.4: Version 0.4:
* Attachments with a Content-ID are now treated as * Attachments with a Content-ID are now treated as

View File

@@ -109,6 +109,8 @@ Most of the options from the Mandrill
`message` struct can be set directly on an :class:`~django.core.mail.EmailMessage` `message` struct can be set directly on an :class:`~django.core.mail.EmailMessage`
(or subclass) object: (or subclass) object:
.. These attributes are in the same order as they appear in the Mandrill API docs...
.. attribute:: track_opens .. attribute:: track_opens
``Boolean``: whether Mandrill should enable open-tracking for this message. ``Boolean``: whether Mandrill should enable open-tracking for this message.
@@ -132,6 +134,11 @@ Most of the options from the Mandrill
``Boolean``: whether Mandrill should automatically generate a text body from the HTML. ``Boolean``: whether Mandrill should automatically generate a text body from the HTML.
Default from your Mandrill account settings. Default from your Mandrill account settings.
.. attribute:: auto_html
``Boolean``: whether Mandrill should automatically generate an HTML body from the plaintext.
Default from your Mandrill account settings.
.. attribute:: inline_css .. attribute:: inline_css
``Boolean``: whether Mandrill should inline CSS styles in the HTML. ``Boolean``: whether Mandrill should inline CSS styles in the HTML.
@@ -149,6 +156,18 @@ Most of the options from the Mandrill
``Boolean``: whether Mandrill should include all recipients in the "to" message header. ``Boolean``: whether Mandrill should include all recipients in the "to" message header.
Default from your Mandrill account settings. Default from your Mandrill account settings.
.. attribute:: tracking_domain
``str``: domain Mandrill should use to rewrite tracked links and host tracking pixels
for this message. Useful if you send email from multiple domains.
Default from your Mandrill account settings.
.. attribute:: signing_domain
``str``: domain Mandrill should for DKIM signing and SPF on this message.
Useful if you send email from multiple domains.
Default from your Mandrill account settings.
.. attribute:: global_merge_vars .. attribute:: global_merge_vars
``dict``: merge variables to use for all recipients (most useful with :ref:`mandrill-templates`). :: ``dict``: merge variables to use for all recipients (most useful with :ref:`mandrill-templates`). ::