Forcing Exim to relay e-mails for my hostname without breaking server functionality like LetsEncrypt

colorian

Verified User
Joined
Oct 19, 2018
Messages
9
Hello,

I am trying to have Exim relay all mails with a destination suffix matching my hostname. I want this, because the hostname in question is only used for DNS and e-mail is actually to be delivered to Microsoft 365 for a specific set of usernames.

I did this by removing the hostname from /etc/virtual/domains and I restarted Exim. This makes sure that Exim won't treat the hostname as a local domain to deliver mail, but instead looks up the MX record (which exists) to deliver mail. This works.

Since Let's Encrypt will automatically re-add the hostname to /etc/virtual/domains when renewing the hostname certificate (why is this the case?), I have a cron script running to periodically check /etc/virtual/domains and remove the hostname from there if it exists and restart Exim. It retrieves the hostname from directadmin.conf, to allow for changing the hostname without having to change the entire script or having to think about it ever again. This works as well.

My question however is:

Should I expect this change to break key functionality within Directadmin or not?

I'm not sure. My Directadmin Users never contact each other by mail, by username using the hostname and they shouldn't: ideally they won't know of each other's existence. So there is no scenario in my head in which Exim should ever route user mail to local users via the hostname. But I just want to make sure that this won't break other functionalities that depend on the domains in /etc/virtual/domains or functionality of the system that routes messages using the server hostname.

Thanks for anyone's input,
Kenneth
 
It's possible that we're both failing to think of something, but I'm pretty sure your method here is the best way to achieve what you're wanting, and that it won't break any other function.

Though I do have to question if the easiest option isn't just having another hostname that is a FQDN that doesn't need to receive email from the server elsewhere. Because then any domain added to DA can just have it's mail switched off at the user level and you no longer need the cron.
 
Back
Top