I may be going about this wrong, so please feel free to constructively correct me if that is the case. TL;DR: I am having issues when sending mail from one domain I own to another domain I own when one domain’s backup MX is hosted by the other domain.
I own/control two domains. For the sake of this discussion, let’s call them “mydomain .com” and “yourdomain .com”. Each domain is hosted on its own Linode, running MIB. The servers are thus called mail.mydomain .com and mail.yourdomain .com, respectively. The DNS entries are set up such that the primary MX for yourdomain .com is mail.yourdomain .com (as you would expect), and a backup MX record of mail.mydomain .com (just in case your Linode is down).
On mail.yourdomain .com, we have an email set up “you@yourdomain .com”. On mail.mydomain .com, we also have that same email account set up (you@yourdomain .com) in case the primary MX is down and your email is sent here.
Additionally, on mydomain .com, I have an email set up “me@mydomain .com”, and this is where the problem comes in. With all services up and running as normal, I would expect all mail sent to you@yourdomain .com to go to the MX server mail.yourdomain .com. However, if I send an email from me@mydomain .com to you@yourdomain .com, it’s always received by the backup MX (the one at mail.mydomain .com). If I send it from any other domain, it correctly routes to the primary MX. The reason for this seems to be because, when sending from mail.mydomain .com, rather than look up the MX record associated with the address you@yourdomain .com, it simply finds that address on the server and thus never sends it out; the message is instead processed internally. That kind of makes sense, because if I had an address like “wife@mydomain .com”, I would expect it to just route the email internally rather than send it out across the Internet, only to end up back at the same place. However, since we’re talking about a different domain here than the one where it originated, I’d like for MIB to first check to see if there is a MX serving that domain before using the internal account.
Is there a way to accomplish this? Of course I could spin up a third Linode, something like backupmx.mydomain .com and then use that as the backup MX for any number of domains, and not use it at all for sending emails. Maybe that’s the proper way to do this. Of course, I would incur the cost of spinning up that additional Linode, and all I’m really trying to do here is establish some cheap and easy form of redundancy. In particular, to protect ourselves from the possible condition that we would get locked out the Linode for some reason, and then the only email address that Linode has to contact us on is hosted on the server that’s down. That could create a real mess. Here again, we could obviously use a “backup address” like gmail or something, but the whole idea here is that we’re trying to completely divorce ourselves from depending on email accounts and providers that live outside of our domain, and services that we don’t have 100% control over.