When I discovered that yet again a certain ISP had blocked my ISP’s smarthost (grr … hotmail), I needed to come up with something for my server’s Exim configuration to automatically route mail through an alternative route. For various reasons I wanted only specific domains to be routed through this domain (I run this other server and it is kind of handy to have an independent mail server that isn’t dependant on it).
This is a slightly unusual setup for Exim.
I started off with setting up a couple of authenticators so that once everything else worked, Exim could actually login :-
myloginMD5: driver = cram_md5 public_name = CRAM-MD5 client_name = USERNAME client_secret = PASSWORD myloginPLAIN: driver = plaintext public_name = PLAIN client_send = ^USERNAME^PASSWORD
At this point, you have a secret in your configuration file, so protect it! There also seems no obvious way to use particular authenticators with particular servers … not to say that this is impossible (it’s hard to find something to do with mail that is impossible with Exim), but I didn’t see a method to do this.
The next step is to run through your test procedure when making changes. Mine was :-
- Reconfigure Exim by sending it a HUP signal.
- Check the paniclog file to make sure it is still running.
- Run through a manual submission of a mail through the SMTP interface.
- Check the main log file to see it worked as expected.
And if you need help running through that test procedure, this would probably be a good time to read up a good deal more about Exim as you probably should not be doing this until you understand a little more.
You don’t really need two authenticators here – you just need one authenticator that matches that offered by the SMTP servers you plan to authenticate to.
The next step is to modify the SMTP driver. Search for the string “driver = smtp”, and change it to look like :-
remote_smtp: driver = smtp hosts_require_auth = LIST-OF-HOSTS hosts_require_tls = LIST-OF-HOSTS
What we are doing here is using the normal driver with two extra options that come into play for the list of hosts (colon separated of course) – one that requires that authentication be used, and another that requires that TLS be used.
The next step of course is to run through the test procedure again.
The final step is to create a new “smarthost” router that applies for a specified list of domains :-
smarthostplusauth: # Deal with SMTP hosts but specifically through an authenticated SMTP server driver = manualroute domains = LIST-OF-DOMAINS transport = remote_smtp route_list = * "server1::587 : server2::587"
This of course applies to only emails that matches your list of domains. If it gets used, the mail is routed through either of “server1” or “server2” on port 587. I used two servers in here, so that Exim would happily deal with a server that was unresponsive, but you might prefer to use a single server.
And of course it’s time to run through the test procedure again.