Djrill 1-2-3ΒΆ
Install Djrill from PyPI:
$ pip install djrill
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
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()