I run an Exim mail server with multiple virtual domains (a setup similar to this). The server is the smarthost for some other servers.
Suppose I have a virtual domain example.com which has a redirect: [email protected]
=> [email protected]
.
When a server wants to use this Exim server to send mail to [email protected]
, I expect that the mail server sends the mail [email protected]
.
All fine so far, but what if the example.com
MX record did not point to this Exim server? Then delivering the mail to [email protected]
would be incorrect.
Is there a way make Exim check MX record validity when using those virtual domain rules? If not, what should I do? The virtual domain list is quite long. Writing a cron script to invalidate (and re-validate) any invalid domains would feel wrong, or at least a bit hacky.
Your expectation:
is wrong. Alias expansion is not done by intermediate servers and mail relays, they should simply forward the mail unmodified to its destination. Alias expansion should only happen for local delivery at the final destination.
If your Exim configuration treats example.net as a local (virtual or not) domain and the MX records for example.net do not point to your Exim server; simply put either the server or the MX records are misconfigured. Exim will simply follow it's configuration and accept mail for example.net for local delivery. Other senders will simply follow the MX priority and either fail to deliver the mail (in case of incorrect MX records) or that is the only mail that will reach the correct destination (when the MX records are correct and Exim will keep mail in local mailboxes that nobody reads).
Maintaining the correct configuration is one of the actual jobs you have as system administrator...