mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Allow all extra message headers in send.
Mandrill has relaxed previous API restrictions on headers. Fixes #58.
This commit is contained in:
@@ -86,7 +86,8 @@ class DjrillBackendTests(DjrillBackendMockAPITestCase):
|
||||
bcc=['bcc@example.com'],
|
||||
cc=['cc1@example.com', 'Also CC <cc2@example.com>'],
|
||||
headers={'Reply-To': 'another@example.com',
|
||||
'X-MyHeader': 'my value'})
|
||||
'X-MyHeader': 'my value',
|
||||
'Message-ID': 'mycustommsgid@example.com'})
|
||||
email.send()
|
||||
self.assert_mandrill_called("/messages/send.json")
|
||||
data = self.get_api_call_data()
|
||||
@@ -94,7 +95,9 @@ class DjrillBackendTests(DjrillBackendMockAPITestCase):
|
||||
self.assertEqual(data['message']['text'], "Body goes here")
|
||||
self.assertEqual(data['message']['from_email'], "from@example.com")
|
||||
self.assertEqual(data['message']['headers'],
|
||||
{ 'Reply-To': 'another@example.com', 'X-MyHeader': 'my value' })
|
||||
{'Reply-To': 'another@example.com',
|
||||
'X-MyHeader': 'my value',
|
||||
'Message-ID': 'mycustommsgid@example.com'})
|
||||
# Mandrill doesn't have a notion of cc.
|
||||
# Djrill just treats cc as additional "to" addresses,
|
||||
# which may or may not be what you want.
|
||||
@@ -217,22 +220,6 @@ class DjrillBackendTests(DjrillBackendMockAPITestCase):
|
||||
# Make sure the image attachments are not treated as embedded:
|
||||
self.assertFalse('images' in data['message'])
|
||||
|
||||
def test_extra_header_errors(self):
|
||||
email = mail.EmailMessage('Subject', 'Body', 'from@example.com',
|
||||
['to@example.com'],
|
||||
headers={'Non-X-Non-Reply-To-Header': 'not permitted'})
|
||||
with self.assertRaises(NotSupportedByMandrillError):
|
||||
email.send()
|
||||
|
||||
# Make sure fail_silently is respected
|
||||
email = mail.EmailMessage('Subject', 'Body', 'from@example.com',
|
||||
['to@example.com'],
|
||||
headers={'Non-X-Non-Reply-To-Header': 'not permitted'})
|
||||
sent = email.send(fail_silently=True)
|
||||
self.assertFalse(self.mock_post.called,
|
||||
msg="Mandrill API should not be called when send fails silently")
|
||||
self.assertEqual(sent, 0)
|
||||
|
||||
def test_alternative_errors(self):
|
||||
# Multiple alternatives not allowed
|
||||
email = mail.EmailMultiAlternatives('Subject', 'Body',
|
||||
@@ -474,4 +461,4 @@ class DjrillMandrillFeatureTests(DjrillBackendMockAPITestCase):
|
||||
msg = mail.EmailMessage('Subject', 'Message', 'from@example.com', ['to1@example.com'],)
|
||||
sent = msg.send(fail_silently=True)
|
||||
self.assertEqual(sent, 0)
|
||||
self.assertIsNone(msg.mandrill_response)
|
||||
self.assertIsNone(msg.mandrill_response)
|
||||
|
||||
Reference in New Issue
Block a user