From 34732a17a3a5d32bb672e056d2b80e7dbee862a0 Mon Sep 17 00:00:00 2001 From: Haos616 Date: Tue, 5 Apr 2016 17:44:09 +0300 Subject: [PATCH] Added support content_subtype https://docs.djangoproject.com/en/1.9/topics/email/#sending-alternative-content-types --- sparkpost/django/message.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sparkpost/django/message.py b/sparkpost/django/message.py index d737398..904b4d5 100644 --- a/sparkpost/django/message.py +++ b/sparkpost/django/message.py @@ -25,9 +25,13 @@ def __init__(self, message): formatted = { 'recipients': message.to, 'from_email': message.from_email, - 'subject': message.subject, - 'text': message.body + 'subject': message.subject } + + if message.content_subtype == 'html': + formatted['html'] = message.body + else: + formatted['text'] = message.body if message.cc: formatted['cc'] = message.cc