Exim

From The Exim Home Page

Exim is a message transfer agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the Internet. It is freely available under the terms of the GNU General Public Licence. In style it is similar to Smail 3, but its facilities are more general. There is a great deal of flexibility in the way mail can be routed, and there are extensive facilities for checking incoming mail. Exim can be installed in place of sendmail, although the configuration of exim is quite different to that of sendmail.

Lists
you can do all sorts of crazy stuff with lists in Exim

File names in Lists
If an item in a domain, host, address, or local part list is an absolute file name (beginning with a slash character), each line of the file is read and processed as if it were an independent item in the list, except that further file names are not allowed, and no expansion of the data from the file takes place. Empty lines in the file are ignored, and the file may also contain comment lines:

For example I found it useful to point a list at a file: domains = /etc/exim/allowed_domain_list.text

You can negate a file too domains = !/etc/exim/bad_domain_list.text

Of course as Exim is fin you can still use ! in the file too to exclude one line, the Exim Docs explain it better

Smart host
You can route mail for only allowed domains if you want: smarthost: drivers = manualroute domains = /etc/exim/allowed_domain_list.text transport = remote_smtp route_data = remote.smarthost.tld no_more

Extra: How to make an exim package

Exim Solaris SMF