Mailgun Setup

Mailgun handles transactional email in the production setup. Connect it once to send account verification, password resets, and other app-driven messages without building a mail pipeline yourself.

Before you start

You should already have:

  • a working production domain such as interviewdb.com
  • access to the DNS provider for that domain
  • a Mailgun account

1. Create or open your Mailgun account

If you do not already have one, sign up at Mailgun.

2. Add a sending domain

In Mailgun, open Sending -> Domains and add your domain or subdomain. Many teams use a dedicated subdomain such as mg.interviewdb.com, but using the root domain can also work if that matches your email plan.

Mailgun will show a set of DNS records to add. Depending on your setup, these usually include:

  • an SPF TXT record
  • one or more DKIM records
  • tracking or return-path CNAME records
  • optional MX records if you also want Mailgun to receive email for that domain

3. Add the DNS records exactly as Mailgun shows them

In your DNS provider:

  • copy each host and value from Mailgun exactly
  • do not simplify the hostnames
  • do not substitute your root domain unless Mailgun explicitly tells you to

Mailgun sometimes uses TXT records for DKIM and sometimes uses CNAME records. Follow the record type shown in your own dashboard, not a screenshot from another guide.

4. Verify the domain in Mailgun

After the DNS records are in place, click Verify DNS settings in Mailgun. DNS changes can take a few minutes to propagate, so do not panic if verification is not instant.

5. Set the Heroku config vars

Once the Mailgun domain is verified, add the credentials to Heroku:

heroku config:set MAILGUN_API_KEY="your-mailgun-api-key"
heroku config:set MAILGUN_DOMAIN="interviewdb.com"

If your Mailgun account is hosted in the EU region, also set:

heroku config:set MAILGUN_API_URL="https://api.eu.mailgun.net/v3"

6. Test email delivery

After deployment, trigger one of the built-in email flows such as:

  • sign-up with email verification
  • password reset
  • admin-generated email notifications

If a message does not arrive:

  • check Heroku logs
  • check the Mailgun activity log
  • confirm the DNS records still match what Mailgun expects

Notes

  • The production settings use Anymail with Mailgun.
  • Local development does not require Mailgun because the boilerplate uses Django's console email backend by default.
  • Add Mailgun MX records only if you want Mailgun to receive mail for that domain. They are not required for basic outbound transactional email.