Installation¶
It’s easiest to install Djrill from PyPI:
$ pip install djrill
If you decide to install Djrill some other way, you’ll also need to install its one dependency (other than Django, of course): the requests library from Kenneth Reitz.
Configuration¶
In your project’s settings.py
:
Add
djrill
to yourINSTALLED_APPS
:INSTALLED_APPS = ( ... "djrill" )
Add the following line, substituting your own
MANDRILL_API_KEY
:MANDRILL_API_KEY = "brack3t-is-awesome"
Override your existing
EMAIL_BACKEND
with the following line:EMAIL_BACKEND = "djrill.mail.backends.djrill.DjrillBackend"
Also, if you don’t already have a DEFAULT_FROM_EMAIL
in settings,
this is a good time to add one. (Django’s default is “webmaster@localhost”,
which won’t work with Mandrill.)
Mandrill Webhooks (Optional)¶
Djrill includes optional support for Mandrill webhooks, including inbound email. See the Djrill webhooks section for configuration details.
Mandrill Subaccounts (Optional)¶
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 subaccount
on each individual message,
with Mandrill-specific sending options.)
New in version 1.0: MANDRILL_SUBACCOUNT global setting
Admin (Optional)¶
Djrill includes an optional Django admin interface, which allows you to:
- Check the status of your Mandrill API connection
- See stats on email senders, tags and urls
If you want to enable the Djrill admin interface, edit your base urls.py
:
... from django.contrib import admin from djrill import DjrillAdminSite admin.site = DjrillAdminSite() admin.autodiscover() ... urlpatterns = [ ... url(r'^admin/', include(admin.site.urls)), ]
If you are on Django 1.7 or later, you will also need to change the config used
by the django.contrib.admin app in your settings.py
:
... INSTALLED_APPS = ( # For Django 1.7+, use SimpleAdminConfig because we'll call autodiscover... 'django.contrib.admin.apps.SimpleAdminConfig', # instead of 'django.contrib.admin' ... 'djrill', ... ) ...