Fixing anymail/mailgun "Domain not found" error

03 Oct · by Tim Kamanin · 1 min read

Are you swearing at mailgun now? Have you smashed your keyboard already? Do you keep receiving the Domain not found: domainname.com error although you're 100% sure you've set everything up correctly?

Yeah, I've been there and probably, I have a solution for you.

Chances are, your domain is set as EU in mailgun. Make sure you use correct API base URL in this case: https://api.eu.mailgun.net/v3, note the eu part. Update example snippets that mailgun gave you with this endpoint and everything should start working just fine.

I'm on Django, and I use Anymail

Me too! Make sure you've added european mailgiun API URL to settings.py:

ANYMAIL = {
    'MAILGUN_API_KEY': '<MAILGUN_API_KEY>',
    'MAILGUN_SENDER_DOMAIN': 'domainname.com',
    'MAILGUN_API_URL': 'https://api.eu.mailgun.net/v3' # add this line!
}

That should be it; now you're happy european mailgun user! You're welcome!

Want to get more 🔥 tips like this one?

Subscribe to get notified about new dev tutorials