Sending emails with mandrill.com, Djrill and Django

Last day I noticed a really cool solution for sending email from MailChimp called Mandrill. It offers free package up to 12000 emails per month and 250 emails per hour. I decided to include it in our project (Django) and give it a go.

Mandrill is a scalable and affordable email infrastructure service, with all the marketing-friendly analytics tools you’ve come to expect from MailChimp.

Because it’s built by famous MailChimp, it has to be really good. I found a nice library for Python called Djrill which nicely wraps django email sending capabilities.

1. Create an account on Mandrill and get API Key

Registration is pretty easy, just follow instructions at https://mandrill.com/signup/

2. Install Djrill (I pulled steps from official docs)

Install Djrill with pip:

Edit your project’s settings.py:

3. Start sending emails

The beauty of Djrill it you don’t have to change code, because it works with current code for sending emails. There are 2 ways to send an email

First:

Or second with EmailMultiAlternatives

There is also a cool feature to add tags and metadata to emails. Later in Mandrill you can filter emails by them. They can be useful to filter different types of emails (registration, newsletter) or for example, to whom you have sent an email (client a, client b, …)