mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
Merge pull request #45 from texastribune/support-html-alternate-content
Fix: Djrill assumes message content type is text
This commit is contained in:
@@ -112,8 +112,9 @@ class DjrillBackend(BaseEmailBackend):
|
||||
to_list = [{"email": to_email, "name": to_name}
|
||||
for (to_name, to_email) in parsed_rcpts]
|
||||
|
||||
content = "html" if message.content_subtype == "html" else "text"
|
||||
msg_dict = {
|
||||
"text": message.body,
|
||||
content: message.body,
|
||||
"subject": message.subject,
|
||||
"from_email": from_email,
|
||||
"to": to_list
|
||||
|
||||
@@ -118,6 +118,17 @@ class DjrillBackendTests(DjrillBackendMockAPITestCase):
|
||||
# Don't accidentally send the html part as an attachment:
|
||||
self.assertFalse('attachments' in data['message'])
|
||||
|
||||
def test_html_only_message(self):
|
||||
html_content = '<p>This is an <strong>important</strong> message.</p>'
|
||||
email = mail.EmailMessage('Subject', html_content,
|
||||
'from@example.com', ['to@example.com'])
|
||||
email.content_subtype = "html" # Main content is now text/html
|
||||
email.send()
|
||||
self.assert_mandrill_called("/messages/send.json")
|
||||
data = self.get_api_call_data()
|
||||
self.assertNotIn('text', data['message'])
|
||||
self.assertEqual(data['message']['html'], html_content)
|
||||
|
||||
def test_attachments(self):
|
||||
email = mail.EmailMessage('Subject', 'Body goes here', 'from@example.com', ['to1@example.com'])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user