mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
use_template_subject and use_template_from
Change "clear_subject" and "clear_from" to clarify expected usage. Update docs. Acknowledge contribution.
This commit is contained in:
@@ -87,7 +87,6 @@ class DjrillBackend(BaseEmailBackend):
|
||||
if getattr(message, 'alternatives', None):
|
||||
self._add_alternatives(message, msg_dict)
|
||||
self._add_attachments(message, msg_dict)
|
||||
self._filter_msg_dict(message, msg_dict)
|
||||
api_params['message'] = msg_dict
|
||||
|
||||
# check if template is set in message to send it via
|
||||
@@ -145,12 +144,16 @@ class DjrillBackend(BaseEmailBackend):
|
||||
content = "html" if message.content_subtype == "html" else "text"
|
||||
msg_dict = {
|
||||
content: message.body,
|
||||
"subject": message.subject,
|
||||
"from_email": from_email,
|
||||
"to": to_list
|
||||
}
|
||||
if from_name:
|
||||
msg_dict["from_name"] = from_name
|
||||
|
||||
if not getattr(message, 'use_template_from', False):
|
||||
msg_dict["from_email"] = from_email
|
||||
if from_name:
|
||||
msg_dict["from_name"] = from_name
|
||||
|
||||
if not getattr(message, 'use_template_subject', False):
|
||||
msg_dict["subject"] = message.subject
|
||||
|
||||
if message.extra_headers:
|
||||
msg_dict["headers"] = message.extra_headers
|
||||
@@ -314,11 +317,3 @@ class DjrillBackend(BaseEmailBackend):
|
||||
'content': content_b64.decode('ascii'),
|
||||
}
|
||||
return mandrill_attachment, is_embedded_image
|
||||
|
||||
def _filter_msg_dict(self, message, msg_dict):
|
||||
"""Filter message data (e.g. clear subject field, or from field)"""
|
||||
if hasattr(message, 'clear_from') and message.clear_from:
|
||||
msg_dict['from_name'] = ''
|
||||
msg_dict['from_email'] = ''
|
||||
if hasattr(message, 'clear_subject') and message.clear_subject:
|
||||
msg_dict['subject'] = ''
|
||||
|
||||
Reference in New Issue
Block a user