I’m trying to set up email delivery through Mailgun but running into some issues with domain configuration. Right now I have the DNS records set up for mg.mydomain.com but I want to send emails from addresses like [email protected] instead of using the mg subdomain.
My main domain already uses Office 365 for email hosting and I need to keep receiving emails there. What I’m hoping to achieve is:
Also send automated emails from Mailgun using the same [email protected] address
Continue receiving all emails through Office 365 like before
I’m worried about deliverability issues since the sending server for Mailgun would be different from where my MX records point. Will adding the proper SPF and DKIM records to my main domain solve this problem or will spam filters still block emails because of the server mismatch?
Has anyone successfully configured this type of setup before? Any advice would be helpful.
This is definitely doable and pretty common actually. I’ve been running a similar setup for about two years now with my company domain. The key thing is getting your SPF record configured correctly to include both Office 365 and Mailgun’s sending servers. You’ll want to update your main domain’s SPF record to include both “include:spf.protection.outlook.com” for Office 365 and “include:mailgun.org” for Mailgun. Something like “v=spf1 include:spf.protection.outlook.com include:mailgun.org ~all” should work. Also make sure you add Mailgun’s DKIM key to your main domain’s DNS records, not just the subdomain. The server mismatch isn’t really an issue as long as your SPF explicitly authorizes Mailgun to send on behalf of your domain. Most modern spam filters rely heavily on SPF/DKIM authentication rather than just checking if the sending server matches your MX records. I haven’t had any deliverability problems with this approach, though you should monitor your reputation closely when you first start sending through Mailgun.
honestly the mx record thing shouldnt worry you too much. ive got mailgun sending from my main domain while using google workspace for receiving and it works fine. just dont forget to test with mail-tester.com or similar after setting up your spf records - caught a syntax error that way once that was causing delivery issues.
You’ll need to configure DKIM signing in Mailgun for your main domain rather than just the subdomain. When you set up the domain in Mailgun’s control panel, add your actual domain (mydomain.com) instead of only using the subdomain approach. This lets you generate the proper DKIM keys that need to be added to your main domain’s DNS zone. I had similar concerns about deliverability when I switched from using a subdomain to the main domain for transactional emails. The reality is that having proper authentication records matters more than server matching these days. Make sure you’re using a dedicated IP through Mailgun if you’re sending significant volume, as this gives you better control over your sending reputation. One thing to watch out for is DMARC policy conflicts - if you have a strict DMARC policy set up, you might need to adjust it to accommodate both sending sources. Start with a small test batch and monitor your delivery rates before scaling up the volume.