5.8. Delivering non-SPAM email

For each non-SPAM email we received we needed to deliver it to the intended recipient, but delivering these mails would require some careful handling because we couldn't use the standard approach of looking up MX records in DNS. (Remember that each hosted domain our service managed would have MX records pointing to our hosts.)

To allow the delivery to be made we used an installation of exim, which was configured with some transports [1] to allow it to discover where to deliver valid email, so that DNS wasn't used. The main transport we used was the "hubbed hosts" which is installed by default in the Debian GNU/Linux sample configuration.

The hubbed_hosts transport allowed us to create a file similar to this for our list of hosted domains:

Example 5-5. /etc/exim4/hubbed_hosts.

hosted.org: mx1.hosted.org : mx2.hosted.org
user.org : mx1.user.org : backup.user.org

This configuration file would ensure that mail sent to user@user.org will be delivered to either mx1.user.org or backup.user.org, with no reliance on the MX records for the domain at all. (The IP addresses for the servers listed would be determined via DNS lookups as expected.)

We used a similar system to specify which port to deliver mail to on a per-domain basis, via the file /etc/exim4/hubbed_ports. Although using port 25 is standard for SMTP servers several users wished to ensure that their mailservers didn't receive traffic which attempted to bypass our service - so they moved their SMTP servers to listening upon non-standard ports.

Each of our hosted domains had the list of MX servers stored beneath the /srv hierarchy in the file /srv/$domain/mx as documented in Section 5.3.

For a real example consider the following two domains:

Table 5-3. Specifying the MX machines for hosted domains.

Domain NameFilenameContents
hosted.org/srv/hosted.org/mx

mx1.hosted.org:25

mx2.hosted.org:25

hosted.com/srv/hosted.com/mxmx1.hosted.com:2525

The contents of these files were read and compiled into the two configuration files "hubbed_hosts" and "hubbed_ports" every few minutes via the script listed in Appendix C.

In addition to using the "hubbed_hosts" and "hubbed_ports" facilities we also made several other changes to the standard configuration of exim as included in Debian's distribution:

Provided that it could be configured to bypass the use of MX records then pretty much any mailserver could have been used to route the non-SPAM email to its final destination. The use of exim was chosen pretty arbitrarily as it is the default mailserver used in Debian GNU/Linux.

Notes

[1]

"transports" and "routers" are exim-specific terms which describe how messages are processed and delivered.