Mailgun routes match_recipient not receiving: why they never fire
Mailgun routes only act on mail that arrives at Mailgun's servers, so they never fire for outbound sending. Point the MX records of a receiving domain or subdomain at Mailgun, make sure the match_recipient pattern matches the address, and give the route a forward() or store() action.
Sohail Hussain9 min readShort answer
- Routes only act on mail that arrives at Mailgun, so sending through SMTP or the API never triggers one. The domain or subdomain that receives the mail needs MX records pointing at Mailgun.
- Publish MX on a dedicated subdomain, make sure the route expression matches the address people write to, and give the route an action such as forward or store.
You set up Mailgun SMTP, outbound mail works, and you added a route with match_recipient to catch replies or incoming messages. Nothing fires. The route looks right in the dashboard, but your app or mailbox never sees a message.
That symptom has one dominant cause: outbound and inbound are separate paths. Outbound needs SPF and DKIM. Inbound needs MX records, a matching route and an action. Fixing one does nothing for the other.
Why it happens
Mailgun describes Routes as a filtering and forwarding mechanism for incoming mail. The causes below are ordered by how often they turn out to be the problem.
| Cause | Symptom | Fix |
|---|---|---|
| No MX at Mailgun | Nothing in the logs for the test message | Add Mailgun MX records on the receiving domain |
| Mail goes to another provider | Replies land in Gmail or Microsoft 365 | Point Reply-To at the Mailgun subdomain |
| Pattern does not match | Mail arrives, no route fires | Fix the regex, check the domain |
| Higher-priority route stopped processing | A catch-all or earlier route handles it | Reorder priorities |
| Route has no useful action | Route matches, nothing visible happens | Add forward() or store() |
| Forward URL fails | Route fires, your app gets nothing | Make the endpoint public and fast |
Mailgun's own troubleshooting article starts with two questions: does the route match the domain name of one of your domains on the account, are the MX records pointing to Mailgun, and are there spelling errors in the route. The rest of this guide works through those and what comes after.
Step-by-step fixes
1. Point MX at Mailgun on a dedicated subdomain
MX records are the one thing routes cannot work without. Mailgun's DNS FAQ says they are only needed if you want to receive incoming mail for the domains you verified in your account, which is why a sending-only setup works without them.
For a US-region domain, publish these on the name that should receive mail:
inbound.example.com. MX 10 mxa.mailgun.org.
inbound.example.com. MX 10 mxb.mailgun.org.
Priority 10 for both is what Mailgun's setup instructions use. For a domain created in the EU region, use the MX values Mailgun shows for that domain in its DNS records.
Use a subdomain. Mailgun's docs warn that adding its MX records breaks an existing mail setup, and a domain should have only one source for its MX records. If you put Mailgun's MX on your root domain while Google Workspace or Microsoft 365 handles it, you can cut off your regular inboxes. Mailgun's own advice for a domain that already has MX elsewhere is to set up a different domain in Mailgun to use your routes with.
- Choose a subdomain such as
inbound.example.com(or a name likereplies). - Add that subdomain in Mailgun if you have not already, so it is one of your account's domains.
- In your DNS provider, add both MX records with priority
10. - Remove any other MX on that exact name.
- Check it from a terminal:
dig MX inbound.example.com +short
You should see both Mailgun hosts. An empty result or another provider means the record has not published or sits on the wrong name. Mailgun's guidance for one related MX change is to allow 24-48 hours for records to fully propagate; in practice it is often faster, but do not conclude it failed after ten minutes.
Common DNS slips:
- Typing the full name in a panel that appends the zone, giving
inbound.example.com.example.com. - Leaving an old MX in place so two providers compete.
- Adding a CNAME on the same name as the MX; a CNAME cannot coexist with other records there.
2. Make sure replies actually go to the Mailgun domain
This is the second most common miss. Replies go to the address in Reply-To, or From if there is no Reply-To. If that address is on a domain whose MX points at Google, Microsoft or your host, the reply never touches Mailgun. Set Reply-To to an address on the receiving subdomain, such as support@inbound.example.com. Return-Path vs Reply-To explains which header controls what.
Do not test from the same address
Mailgun has a separate help article for the case where the sending and receiving addresses match, so test from a personal mailbox on a different domain first, then try variations.
3. Fix the match_recipient expression
match_recipient filters incoming messages by recipient address. Mailgun's example is an address like info@mail.example.com, where mail.example.com is the domain verified on your account. The argument is a regular expression, so anchor and escape it:
match_recipient("^support@inbound\\.example\\.com$")
match_recipient(".*@inbound\\.example\\.com")
match_header("subject", ".*invoice.*")
catch_all()
Check these:
- Domain in the pattern. It must be the receiving subdomain, not your root or sending domain.
- Escaping. Dots need escaping, and backslashes often get eaten by shells or JSON when you create routes from a script.
- Priority. The lower the number, the higher the priority, and the lowest number is handled first. A broad route at a low number can swallow mail before your specific route runs.
stop()in an earlier route. A matching route that ends instop()prevents later ones from seeing the message.
Mailgun also provides a Routes Tester: you can test which route an email address would trigger if someone sent to it. Use it before sending real mail.
4. Give the route an action
A filter alone does nothing visible. Mailgun lists three actions: forward, store and notify, and stop. Forward sends the message to an email address or an endpoint on your server. Store keeps it temporarily; Mailgun says up to 7 days, depending on your plan and the domain's settings, retrievable through the Messages API.
To create a route in the dashboard, open the Send product, then Receiving, switch to the right region, and click Create route. Menu labels change, so if yours differ, search Mailgun's help center for "Routes".
Through the API (US region; EU accounts use api.eu.mailgun.net):
curl -s --user 'api:YOUR_API_KEY' https://api.mailgun.net/v3/routes \
-F priority=1 \
-F description='Support inbound' \
-F expression='match_recipient("^support@inbound\\.example\\.com$")' \
-F action='forward("https://app.example.com/hooks/mailgun")' \
-F action='stop()'
Make sure the region of the route matches the region of the domain. A route created in the wrong region will never see that domain's mail.
5. Check the forward endpoint
If the logs show the route fired but your app saw nothing, the problem is on your side. The URL must be publicly reachable (not localhost), must not redirect, and must accept form-encoded POST data rather than expecting JSON. Return a 200 status quickly, and do heavy work after responding.
Test it and read the logs
- Send a message from a personal mailbox on another domain to
support@inbound.example.com. - Open the Mailgun logs for that domain. If nothing appears, mail never reached Mailgun: go back to step 1 and 2.
- If it appears but your app got nothing, check the expression, priority and action.
- If your app received it and errored, fix the endpoint.
Relaying denied means the opposite problem
If a sender gets a Relaying Denied bounce, MX already points at Mailgun but no route catches that recipient address. Mailgun says this happens when the account does not have a route or is not configured to catch the address, so add or correct the route.
Checklist before you try again
- The receiving domain is added in Mailgun, in the right region.
dig MXon that exact name returns only Mailgun's two hosts.- Your root domain's MX records were not changed.
Reply-Topoints at an address on the receiving subdomain.- The expression names the receiving subdomain and escapes the dots.
- No lower-numbered route or
stop()intercepts the message. - The route has a forward or store action.
- The forward URL is public and returns 200.
What routes cannot do
Mailgun is not a mailbox host. One help article says Mailgun does not host mailboxes, so its service does not use POP or IMAP, though it can forward incoming email somewhere else, such as a personal address or a webhook. If people need to read and answer replies, forward to a real mailbox or build a handler in your own app. A route also cannot see mail that was delivered to another provider.
If nothing works
Contact Mailgun support only after dig shows correct MX and a test message leaves no trace in the logs. Include the receiving domain, region, exact recipient address, test time with timezone, the dig MX output and the route expression. Raw headers of the test message help; our email header analyzer can read them first.
Subject: Route not firing for inbound.example.com (US region)
Hello,
Mail sent to support@inbound.example.com does not appear in the logs
and the route below never fires.
Domain: inbound.example.com (US region)
Route ID/expression: match_recipient("^support@inbound\\.example\\.com$")
Test sent: 2026-11-30 14:05 UTC from a Gmail address
dig MX inbound.example.com +short output:
{paste output}
MX has been published for more than 24 hours. Could you check whether
the domain is set up for receiving?
For reference, Mailgun's Routes help article and its route troubleshooting page cover the dashboard side.
Common questions
Can I use my root domain for Mailgun routes?
Only if nothing else receives mail there. A domain should have one source of MX records, so Mailgun on the root would displace Google Workspace or Microsoft 365 inboxes. A subdomain avoids that.
Do I need MX records to send through Mailgun?
No. Mailgun's DNS FAQ says the two TXT records (SPF and DKIM) are all that's required to send; MX and CNAME are optional.
Why does the route work in the Routes Tester but not with real mail?
The tester only checks which route an address would trigger. It does not prove that mail reaches Mailgun. If real messages do not show in the logs, the MX or the Reply-To address is the problem.
Can a route read replies like an inbox?
No. A route forwards or stores messages; it does not give you a mailbox to browse. Forward to a mailbox or your own app.
Explore: Email Marketing Strategy
Related Articles
Mailgun account disabled or suspended without warning: what to do
If Mailgun disabled your account without warning, reply to the notice with complete answers to every verification question, and move production mail to a second provider that is already authenticated. The lasting fix is a tested backup, rotated API keys and signup forms that bots cannot abuse.
Mailgun 401 Unauthorized (MailgunAPIError): Cause and Fix
Mailgun returns a 401 when the API key, the domain or the region in your request doesn't match your account. Use a key from the same account, send through a domain that key can access, and point the client at api.eu.mailgun.net if the domain was created in the EU region.
Mailgun pricing: what happened to the free plan (2026)
Users report that Mailgun retired its old free tier around 2022-2023 and that the cheapest sensible paid plan became about $35 a month. Plans change often, so verify on Mailgun's pricing page. If it is too steep, compare per-message relays such as Amazon SES, Brevo, Postmark or Resend at your own volume.
Mailgun: "The 'address' parameter should be a valid email address"
Mailgun returns this error when the address sent to its mailing list API is empty or malformed. The usual causes are a blank field in your export, stray whitespace, a display name mixed into the address, or an unencoded plus sign. Find the bad value, clean it, and resend.
Ready to supercharge your email marketing?
Start sending smarter emails with AI-powered campaigns. No credit card required.
Get Started Free