Skip to content

Commit

Permalink
Subject and Text-part are optional. Add Mj-EventPayload property
Browse files Browse the repository at this point in the history
  • Loading branch information
kidig committed Apr 3, 2016
1 parent eb32144 commit 0e85bb2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions django_mailjet/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 0e85bb2

Please sign in to comment.