Unable to send emails from root domain after Mailgun setup

I’ve hit a snag while configuring email for my website. I set up Mailgun with a subdomain (mg.mydomain.com) and it works fine for sending from that subdomain. But when I try to use the root domain (mydomain.com), I get an error saying the domain isn’t found.

Here’s what I’ve done so far:

  • Set up DNS with DigitalOcean
  • Linked a Gmail account to my domain
  • Configured Mailgun with mg.mydomain.com
  • Completed Mailgun verification

The error I’m seeing looks like this:

AnymailRequestsAPIError: Sending a message to [email protected] from [email protected]
ESP API response 404:
{
  "message": "Domain not found: mydomain.com"
}

Any ideas on how to fix this? I’d really like to send from my root domain. Thanks!

Have you considered using a custom SMTP server instead of Mailgun? I’ve found this approach more flexible for handling multiple domains. You’d need to set up an SMTP server on your host, configure the necessary DNS records (MX, SPF, DKIM), and then update your application’s email settings to use this SMTP server. This method allows sending from both root and subdomains without the limitations you’re experiencing with Mailgun. It does require more initial setup, but it gives you full control over your email infrastructure. Just ensure your server is properly secured to prevent abuse.

I encountered a similar issue when setting up Mailgun for a client’s website. In my case, the resolution was to configure the root domain as a separate entity within Mailgun instead of relying solely on the subdomain. I logged into my Mailgun account, navigated to the Domains section, and then added my root domain. I made sure to update the DNS records with the required SPF and DKIM entries and waited for the verification process to complete, which sometimes takes a few hours. After that, the emails began sending correctly from the root domain. I recommend verifying that your app is configured to use the correct domain when dispatching emails.

hey mate, maybe u dint add the root domain in mailgun. just add it in the domains section, update dns with spf & dkim, and wait for verification. also doublecheck the sending config in ur app. good luck!