From 0e85bb26341283eaa3192b599a06bb46b9baac04 Mon Sep 17 00:00:00 2001 From: kidig Date: Sun, 3 Apr 2016 20:13:59 +0300 Subject: [PATCH] Subject and Text-part are optional. Add Mj-EventPayload property --- django_mailjet/backends.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/django_mailjet/backends.py b/django_mailjet/backends.py index 7bf27b1..13b6a5f 100644 --- a/django_mailjet/backends.py +++ b/django_mailjet/backends.py @@ -95,10 +95,13 @@ def parse_response(self, response, payload, message): email_message=message, payload=payload, response=response) def _build_standart_message_dict(self, message): - msg_dict = { - 'Subject': message.subject, - 'Text-part': message.body, - } + msg_dict = dict() + + if len(message.subject): + msg_dict['Subject'] = message.subject + + if len(message.body): + msg_dict['Text-part'] = message.body sender = sanitize_address(message.from_email, message.encoding) from_name, from_email = parseaddr(sender) @@ -136,6 +139,7 @@ def _add_mailjet_options(self, message, msg_dict): 'track_open': 'Mj-trackopen', 'track_click': 'Mj-trackclick', 'custom_id': 'Mj-CustomID', + 'event_payload': 'Mj-EventPayLoad', } for attr, mj_attr in mailjet_attrs.items():