Skip to content
Djrill is an email backend and new message class for Django users that want to take advantage of the Mandrill transactional email service from MailChimp.
Python
Find file
Latest commit f95d5d6 @medmunds medmunds Avoid weak ref to local signal receiver in webhook tests.
Webhook tests define a local signal receiver function,
so connect it using the `weak=False` option to set
a good example.

(This isn't technically needed in the tests: the test receivers
are only connected while their definitions are still in scope,
so they couldn't possibly be garbage collected. But it doesn't
hurt, and it's good practice in case the test code gets copied.)

Also update the webhook docs to have a direct link to
Django's "listening to signals" info.

README.rst

Djrill: Mandrill Transactional Email for Django

Djrill integrates the Mandrill transactional email service into Django.

UPGRADING FROM DJRILL 1.x? There are some breaking changes in Djrill 2.0. Please see the upgrade instructions.

In general, Djrill "just works" with Django's built-in django.core.mail package. It includes:

  • Support for HTML, attachments, extra headers, and other features of Django's built-in email
  • Mandrill-specific extensions like tags, metadata, tracking, and MailChimp templates
  • Optional support for Mandrill inbound email and other webhook notifications, via Django signals

Djrill is released under the BSD license. It is tested against Django 1.4--1.9 (including Python 3 with Django 1.6+, and PyPy support with Django 1.5+). Djrill uses semantic versioning.

build status on Travis-CI

Resources

Djrill 1-2-3

  1. Install Djrill from PyPI:

    $ pip install djrill
  2. Edit your project's settings.py:

    INSTALLED_APPS = (
        ...
        "djrill"
    )
    
    MANDRILL_API_KEY = "<your Mandrill key>"
    EMAIL_BACKEND = "djrill.mail.backends.djrill.DjrillBackend"
    DEFAULT_FROM_EMAIL = "you@example.com"  # if you don't already have this in settings
  3. Now the regular Django email functions will send through Mandrill:

    from django.core.mail import send_mail
    
    send_mail("It works!", "This will get sent through Mandrill",
        "Djrill Sender <djrill@example.com>", ["to@example.com"])

    You could send an HTML message, complete with custom Mandrill tags and metadata:

    from django.core.mail import EmailMultiAlternatives
    
    msg = EmailMultiAlternatives(
        subject="Djrill Message",
        body="This is the text email body",
        from_email="Djrill Sender <djrill@example.com>",
        to=["Recipient One <someone@example.com>", "another.person@example.com"],
        headers={'Reply-To': "Service <support@example.com>"} # optional extra headers
    )
    msg.attach_alternative("<p>This is the HTML email body</p>", "text/html")
    
    # Optional Mandrill-specific extensions:
    msg.tags = ["one tag", "two tag", "red tag", "blue tag"]
    msg.metadata = {'user_id': "8675309"}
    
    # Send it:
    msg.send()

See the full documentation for more features and options.

Something went wrong with that request. Please try again.