I’m running mailcow on a subdomain of a domain I want to accept mail for. I also use Mailgun using a transport map for all outgoing email. This results in a mail loop. For example:
Mailcow is hosted on mail.app.example.com
Mailcow has a domain ‘example.com’ configured with a mailbox ‘firstname.lastname@example.org’.
Mailcow has a transport map with destination ‘*’ and nexthop Mailgun.
When a mail arrives for email@example.com, it is not delivered to the mailbox. Instead, it is relayed to Mailgun, which then relays it back to Mailcow. This repeats until the max hop count is reached, and the mail is dropped.
I assume this has something to do with that ‘mail.app.example.com’ is a subdomain of ‘example.com’. Mail for other domains works fine. This setup also doesn’t properly generate ACME certificates for ‘example.com’, only the subdomain.
Any ideas on how to resolve this? I would rather not host Mailcow in the root of the domain.