mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 11:51:05 -05:00
ability to use default Mandrill subject and from fields
This commit is contained in:
@@ -87,6 +87,7 @@ 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
|
||||
@@ -310,3 +311,10 @@ class DjrillBackend(BaseEmailBackend):
|
||||
'content': content_b64.decode('ascii'),
|
||||
}
|
||||
return mandrill_attachment, is_embedded_image
|
||||
|
||||
def _filter_msg_dict(self, message, msg_dict):
|
||||
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'] = ''
|
||||
|
||||
@@ -37,6 +37,26 @@ and will ignore any `body` text set on the `EmailMessage`.
|
||||
All of Djrill's other :ref:`Mandrill-specific options <mandrill-send-support>`
|
||||
can be used with templates.
|
||||
|
||||
How To Use Default Mandrill Subject and From fields
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.. versionadded:: dev
|
||||
Mandrill default fields support
|
||||
|
||||
To use default *Mandril* subject or default from field you need send message
|
||||
to *Mandril* with empty subject or empty from field. This can be done using
|
||||
the following attrs: :attr:`clear_subject` and :attr:`clear_from` on
|
||||
your :class:`~django.core.mail.EmailMessage` object::
|
||||
# ...
|
||||
msg.clear_subject = True
|
||||
msg.clear_from = True
|
||||
msg.send()
|
||||
|
||||
If :attr:`clear_subject` is set, Djrill will send message without subject and
|
||||
Mandrill will use default subject.
|
||||
|
||||
If :attr:`clear_from` is set, Djrill will send message without from field and
|
||||
Mandrill will use default from field.
|
||||
|
||||
|
||||
.. _django-templates:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user