How can I setup Mailgun on Django?

Issue

I want to setup the Mailgun add-on for Django on Heroku

Resolution

You can use Mailgun as an SMTP relay; there is more information about that here.

When using Heroku and the Mailgun add-on, all of the necessary Mailgun variables are stored as environmental variables. You can update your Django project's settings.py file with the following variables.

EMAIL_HOST = os.environ.get('MAILGUN_SMTP_SERVER', '')
EMAIL_PORT = os.environ.get('MAILGUN_SMTP_PORT', '')
EMAIL_HOST_USER = os.environ.get('MAILGUN_SMTP_LOGIN', '')
EMAIL_HOST_PASSWORD = os.environ.get('MAILGUN_SMTP_PASSWORD', '')

With these changes saved and re-deployed to your Heroku app, you should be able to utilize Django's built-in email functionality, and the application will use the Mailgun-configured email provider via SMTP relay.

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support