We have a problem that I've done a fair bit of research on without success. We're on a shared web hosting server running cPanel / WHM. Some of our domains have email services running on the same server and some have their own email server.
We had an initial problem where mail would not flow between domains that had mail hosted on the server and those that hosted their own email. The solution to this problem was to remove each domain entry from /etc/localdomains and add it to /etc/remotedomains for the domains that hosted their own mail.
The above solution worked fine until someone made a DNS change to their domain - what happens in this case is that if you edit a DNS zone in WHM, the domain ends up back in etc/localdomains. We figured the way to fix this is to un-check the "accept mail locally" option on the Edit DNS zone page in WHM. Unfortunately this doesn't work. Having also tried un-checking the same option on the cPanel/MX Entry maintenance page with no result it seems that our only option is to email our web hosts every time there is a DNS change and ask them to manually edit etc/localdomains and etc/remotedomains.
Clearly, this option - although it works - is prone to all sorts of issues and a major pain in the a***.
Have any of you dealt with this issue before?