Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Commit

Permalink
Subaccounts: Document setting; verify message option overrides global…
Browse files Browse the repository at this point in the history
… setting
  • Loading branch information
medmunds committed Apr 20, 2014
1 parent 7e928dc commit ba2302a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions AUTHORS.txt
Expand Up @@ -12,3 +12,5 @@ peillis
José Padilla
Jens Alm
Eric Hennings
Michael Hobbs
Sameer Al-Sakran
11 changes: 11 additions & 0 deletions djrill/tests/test_mandrill_subaccounts.py
Expand Up @@ -34,3 +34,14 @@ def test_send_from_subaccount(self):
self.assertEqual(len(data['message']['to']), 1)
self.assertEqual(data['message']['to'][0]['email'], "to@example.com")
self.assertEqual(data['message']['subaccount'], settings.MANDRILL_SUBACCOUNT)

def test_subaccount_message_overrides_setting(self):
settings.MANDRILL_SUBACCOUNT = "global_setting_subaccount"
message = mail.EmailMessage(
'Subject here', 'Here is the message',
'from@example.com', ['to@example.com'])
message.subaccount = "individual_message_subaccount" # should override global setting
message.send()
self.assert_mandrill_called("/messages/send.json")
data = self.get_api_call_data()
self.assertEqual(data['message']['subaccount'], "individual_message_subaccount")
22 changes: 22 additions & 0 deletions docs/installation.rst
Expand Up @@ -15,6 +15,8 @@ library from Kenneth Reitz.
Configuration
-------------

.. setting:: MANDRILL_API_KEY

In your project's :file:`settings.py`:

1. Add :mod:`djrill` to your :setting:`INSTALLED_APPS`::
Expand All @@ -40,6 +42,26 @@ Djrill includes optional support for Mandrill webhooks, including inbound email.
See the Djrill :ref:`webhooks <webhooks>` section for configuration details.


Mandrill Subaccounts (Optional)
-------------------------------

.. setting:: MANDRILL_SUBACCOUNT

If you are using Mandrill's `subaccounts`_ feature, you can globally set the
subaccount for all messages sent through Djrill::

MANDRILL_SUBACCOUNT = "client-347"

(You can also set or override the :attr:`subaccount` on each individual message,
with :ref:`Mandrill-specific sending options <mandrill-send-support>`.)

.. versionadded:: 1.0
MANDRILL_SUBACCOUNT global setting


.. _subaccounts: http://help.mandrill.com/entries/25523278-What-are-subaccounts-


Admin (Optional)
----------------

Expand Down
2 changes: 2 additions & 0 deletions docs/usage/sending_mail.rst
Expand Up @@ -199,6 +199,8 @@ Most of the options from the Mandrill
.. attribute:: subaccount

``str``: the ID of one of your subaccounts to use for sending this message.
(The subaccount on an individual message will override any global
:setting:`MANDRILL_SUBACCOUNT` setting.)

.. versionadded:: 0.7

Expand Down

0 comments on commit ba2302a

Please sign in to comment.