I’m trying to set up Mailgun for programmatic email handling through their API, but I also need regular email accounts that work with standard email clients like Outlook or similar programs.
Specifically, I want to create standard mailboxes for:
info@
marketing@
contact@
While routing all remaining incoming messages through the API for automated processing.
The challenge is that I need to send replies from the original email addresses (like [email protected]), so redirecting to external services like Gmail won’t work for my use case.
How can I configure this mixed setup where some addresses work as normal mailboxes while others are handled programmatically?
Skip the complex routing and separate mail servers - there’s a cleaner way.
Build a smart email processor that handles both scenarios automatically. When emails hit your domain, check the recipient against your standard mailboxes (info@, marketing@, contact@). Match? Store it in proper mailbox format for Outlook. No match? Run your automation.
Replies from original addresses go through Mailgun’s API with the right sender. No auth headaches since it’s all one system.
I use Latenode for this - connects directly to Mailgun webhooks and creates IMAP mailboxes on the fly. Processes every incoming email, sorts instantly, and maintains both automated responses and regular mailboxes without manual config.
Perfect for mixed setups. Your team gets normal email while automation handles everything else.
I’ve hit this exact problem before. Skip trying to configure everything manually in Mailgun - automation handles the routing way better.
Set up a webhook endpoint that catches all incoming emails from Mailgun, then routes based on recipient address. Standard mailboxes (info@, marketing@, contact@) get forwarded to your email server. Everything else goes through your API logic.
The tricky bit: you still need to send from those original addresses. Keep your email server handling standard mailboxes completely. Use Mailgun’s API for automated responses.
I built this with Latenode since it nails webhook processing and has email integrations baked in. The workflow:
Catches Mailgun webhook
Checks recipient against your whitelist
Forwards to email server or processes automatically
Sends responses with correct sender address
Runs itself - no server maintenance. Visual workflow building makes debugging email routing way easier than custom code.
Set up Mailgun routes for your standard mailboxes first - these should forward emails to your email server (Postfix or Exchange). Give these routes higher priority than your catch-all API route so they get handled first. Then create a lower priority route that catches everything else and sends it to your webhook. For replies from original addresses, just use the “from” parameter in Mailgun’s sending API to specify whatever address you want. Don’t forget to update your SPF and DKIM records to include both your email server and Mailgun - otherwise your emails might get flagged as spam. Keep your standard mailbox stuff on a traditional email server separate from the automated processing that Mailgun handles.
Honestly, the easiest approach is using Mailgun’s inbound routing - but backwards from what most people think. Keep your regular mailboxes on a completely separate mail server. Don’t mix them with Mailgun at all. Then set up Mailgun to only catch emails that aren’t going to those specific addresses. Works like a charm and way fewer headaches with authentication issues.
The trick is getting Mailgun to play nice with your regular IMAP/POP3 mailboxes. Here’s what worked for me: split things up with subdomains. Run your normal mailboxes on mail.yourdomain.com with whatever email server you’re using, then let Mailgun handle the main domain. Update your MX records so the main domain points to Mailgun, then use Mailgun’s forward action to bounce specific addresses back to your mail server. Watch out for the authentication stuff though - your DMARC policy needs to allow both servers to send. When you use Mailgun’s API to reply from marketing@ addresses, everything authenticates correctly since Mailgun’s handling that domain’s mail. You get proper mailboxes for your team and clean automated processing.