Mailgun MX Records: How to Set Up Inbound Email Receiving
Learn how to configure Mailgun MX records to receive inbound email, set up routing rules, and verify your setup with a free MX record checker.
Most people know Mailgun as the service that sends transactional emails: order confirmations, password resets, notifications. What fewer people realize is that Mailgun can also receive email. If you want to process inbound messages programmatically (routing support requests to your helpdesk, triggering workflows from email, or capturing form submissions sent via email), Mailgun's inbound routing is worth knowing about.
This guide walks you through setting up Mailgun MX records for inbound email receiving, step by step.
What You Need Before You Start
To receive email through Mailgun, you need:
- A Mailgun account with a verified sending domain (the domain must already be set up in Mailgun for sending)
- Access to your domain's DNS settings at your registrar or DNS provider
- A destination for inbound email (either a webhook URL or a forwarding address)
If you have not yet added your domain to Mailgun at all, start in the Mailgun dashboard under Sending > Domains and complete the sending setup first. The inbound MX records work alongside the sending configuration.
Mailgun's MX Record Values
Unlike sending setup (which uses TXT records for SPF and DKIM), receiving email requires MX records that point to Mailgun's mail servers. Mailgun uses two inbound mail servers at equal priority:
Host: @ (your root domain, e.g. example.com)
Value: mxa.mailgun.org
Priority: 10
Host: @
Value: mxb.mailgun.org
Priority: 10
Both records have priority 10, which means they share the load equally. If one server is unavailable, sending servers will automatically try the other. This gives you redundancy without any extra configuration on your part.
Step 1: Add MX Records at Your DNS Provider
Log into wherever you manage DNS for your domain. This might be your domain registrar (GoDaddy, Namecheap, Porkbun, IONOS) or a separate DNS provider (Cloudflare, AWS Route 53).
Find the section for DNS records and add two new MX records:
First record:
- Type: MX
- Host / Name: @ (or leave blank, depending on your provider)
- Mail Server / Value: mxa.mailgun.org
- Priority: 10
- TTL: 3600 (or the default)
Second record:
- Type: MX
- Host / Name: @
- Mail Server / Value: mxb.mailgun.org
- Priority: 10
- TTL: 3600
Save both records. DNS changes can take anywhere from a few minutes to a few hours to propagate across the internet, so do not panic if things do not work instantly.
Step 2: Verify the MX Records Are Live
Before moving on, confirm that your MX records are actually publishing correctly. Head to mxrecordchecker.com and enter your domain name. You should see both mxa.mailgun.org and mxb.mailgun.org listed with priority 10.
If you only see one of the two records, or you see old MX records from a previous email provider, double-check your DNS settings. It is common to forget to remove old MX records when switching providers, and any leftover records will compete with your Mailgun records and can cause delivery issues.
Step 3: Create an Inbound Route in Mailgun
Adding MX records tells the internet to deliver email to Mailgun. But Mailgun still needs to know what to do with that email once it arrives. That is handled through Mailgun Routes.
In the Mailgun dashboard:
- Go to Receiving > Routes
- Click Create Route
- Set a Filter Expression, which determines which incoming messages the route applies to. A catch-all looks like:
match_recipient(".*@yourdomain.com") - Set an Action: either forward to an email address, post to a webhook URL, or store the message
- Set a Priority: lower numbers run first if you have multiple routes
- Click Create Route
For most small businesses, the simplest setup is forwarding: any email to your domain gets forwarded to your regular inbox. The webhook option is more powerful: Mailgun will POST the email content to a URL you specify, which lets your application process it programmatically.
Why Use Mailgun for Inbound Email?
Webhook-Based Email Processing
If your business has a workflow that starts with an email (a customer submits a support request, a supplier sends an order confirmation, a user replies to a notification), Mailgun can turn that email into a webhook event your application can act on immediately.
Instead of having a human check an inbox and copy data into another system, Mailgun parses the email and sends the content (sender, subject, body, attachments) as a structured HTTP POST to your app or automation tool (Zapier, Make, n8n).
Email-to-App Integrations
Some businesses use email addresses as lightweight intake forms. A unique address like orders+customerid@yourdomain.com can route directly to an order processing workflow. Mailgun's route filters can match on recipient patterns, sender addresses, or even the subject line.
SPF and DKIM for Mailgun
If you are already using Mailgun for sending, you likely have SPF and DKIM records set up. These records stay in place when you add inbound routing, as they work independently. Your SPF record should include include:mailgun.org to authorize Mailgun's servers to send on your behalf.
If you are only setting up inbound and not yet sending through Mailgun, you do not strictly need SPF and DKIM for receiving. Those records protect outgoing email, not incoming.
Common Mistakes to Avoid
Leaving old MX records in place. If your domain previously pointed to another email provider and you did not remove those MX records, you now have competing records. Some email will go to Mailgun, some will go to the old provider. Always remove old MX records before adding new ones, or immediately after.
Forgetting to create a Route. MX records alone only get the email to Mailgun's servers. Without a Route, Mailgun accepts the message and discards it. You must create at least one Route to do anything useful with inbound mail.
Using Mailgun for primary business email. Mailgun is built for programmatic email processing, not for reading email in Outlook or Gmail. If your team needs a regular inbox, use Google Workspace or Microsoft 365 for the root domain and consider routing a subdomain (like inbound.yourdomain.com) to Mailgun instead.
Not testing with real email. After setup, send a test message to an address at your domain and confirm it triggers your route correctly. Check the Mailgun dashboard under Receiving > Logs to see if the message was received and what action was taken.
What to Do If Inbound Email Is Not Working
Start by re-running your domain through mxrecordchecker.com. If the tool shows the correct Mailgun MX records, the problem is likely with your Routes configuration rather than DNS. If the tool shows incorrect or missing records, you have a DNS problem to fix first.
In the Mailgun dashboard, the Receiving > Logs section shows every inbound message and what happened to it, including any errors. This is the fastest way to diagnose routing problems.