MailGun as an SMTP Server for Django Apps Posted on 2011-06-07 by Dave Fowler

Gmail is a frequently used SMTP host for Django apps. Its free and relatively simple to setup which is ideal for small apps. There are a few significant downfalls. First, its limited to 500 emails a day with no option to upgrade. Second, it limits and even re-writes all outgoing emails to the username of the connector.

For example if you're trying to send an email from or you're out of luck because all of those emails will actually get sent at or whatever email account you have configured. I'm sure this saves millions of people from millions of spam but it adds a bit of annoyance to developer's lives.

The recently launched MailGunoffers a great solution. Its free for up to 200 emails per day and super cheap and dramatically scalable after that. It also works as a drop in replacement for whatever service you were using for your django smtp server. Changing will take you less time than reading this article.

The Steps:

  1. Sign up for MailGun
  2. Go to the control panel and click on the server created for you.
  3. In the upper right you will find your "SMTP Authentication" credentials for this server.
    1. Open the in your django app and configure your email with the given credentials. It should look something like this.
      EMAIL_USE_TLS = True
      EMAIL_HOST = ''
      EMAIL_HOST_USER = ''
      EMAIL_PORT = 587
  4. Test it out!
./ shell
>>> from django.core.mail import send_mail
>>> send_mail('MailGun works great!', 'It really really does.', '', [''], fail_silently=False)