I’m trying to set up Mailgun for sending emails from my web app. I need to send both newsletter campaigns and transaction emails to users.
I created a subdomain called “mail.example.com” and added all the DNS records that Mailgun requires. But I couldn’t add the MX record because my domain host doesn’t support MX records for subdomains. They only allow MX records on the main domain and their support team won’t help with this.
I don’t want to use my main domain for Mailgun because we already receive regular business emails there through different mail servers.
Most emails work fine when I send from “[email protected]” to major providers like Gmail and Yahoo. But some email services reject my messages. I get bounce errors like:
I hit this same issue when setting up Mailgun. Email servers do reverse DNS lookups on your bounce domain, and without MX records they’ll flag your messages as spam. Here’s what fixed it for me: use Mailgun’s tracking domains feature to set up a custom return path. Don’t use your subdomain for bounces - create a CNAME record that points to Mailgun’s infrastructure instead. Your sending domain stays the same, but bounces get routed through their verified domains. Go to Sending > Domains in your Mailgun dashboard and find the tracking domain settings. Set up something like ‘track.example.com’ with a CNAME pointing to Mailgun’s servers. Then update your API calls to use this tracking domain for bounce handling. This completely solved our delivery problems with picky email providers. Your main domain stays separate from Mailgun, and bounce processing works perfectly without needing MX records on your subdomain.
Your bounce handling config is definitely the problem. I hit the same delivery issues when I first set up Mailgun - lots of email servers do strict validation on return-path domains. You need to change your envelope sender settings, not your from address. In Mailgun’s API config, you can set a different domain for the return-path header while keeping your main sending domain unchanged. I bought a cheap secondary domain just for this since my hosting provider had the same MX record limits. Set up MX records on this dedicated bounce domain and configure Mailgun to use it only for return-path processing. Users still see emails from your main domain, but bounce handling runs through the properly configured domain. Costs maybe $10/year for the extra domain but totally fixed my delivery problems with corporate servers that check SPF and bounce domains thoroughly.
check if ur domain provider supports cname flattening or alias records instead of mx records. some hosts use different names but they work the same way. id also reach out to mailgun support directly - they’ve got workarounds for tricky hosting setups like this. worst case, you could move just dns management to cloudflare (keep ur domain where it is) since they handle subdomain mx records without issues.