48. Using Exim as a non-queueing client

On a personal computer, it is a common requirement for all email to be sent to a “smart host”. There are plenty of MUAs that can be configured to operate that way, for all the popular operating systems. However, there are some MUAs for Unix-like systems that cannot be so configured: they submit messages using the command line interface of /usr/sbin/sendmail. Furthermore, utility programs such as cron submit messages this way.

If the personal computer runs continuously, there is no problem, because it can run a conventional MTA that handles delivery to the smart host, and deal with any delays via its queueing mechanism. However, if the computer does not run continuously or runs different operating systems at different times, queueing email is not desirable.

There is therefore a requirement for something that can provide the /usr/sbin/sendmail interface but deliver messages to a smart host without any queueing or retrying facilities. Furthermore, the delivery to the smart host should be synchronous, so that if it fails, the sending MUA is immediately informed. In other words, we want something that extends an MUA that submits to a local MTA via the command line so that it behaves like one that submits to a remote smart host using TCP/SMTP.

There are a number of applications (for example, there is one called ssmtp) that do this job. However, people have found them to be lacking in various ways. For instance, you might want to allow aliasing and forwarding to be done before sending a message to the smart host.

Exim already had the necessary infrastructure for doing this job. Just a few tweaks were needed to make it behave as required, though it is somewhat of an overkill to use a fully-featured MTA for this purpose.

There is a Boolean global option called mua_wrapper, defaulting false. Setting mua_wrapper true causes Exim to run in a special mode where it assumes that it is being used to “wrap” a command-line MUA in the manner just described. As well as setting mua_wrapper, you also need to provide a compatible router and transport configuration. Typically there will be just one router and one transport, sending everything to a smart host.

When run in MUA wrapping mode, the behaviour of Exim changes in the following ways:

The overall effect is that Exim makes a single synchronous attempt to deliver the message, failing if there is any kind of problem. Because no local deliveries are done and no daemon can be run, Exim does not need root privilege. It should be possible to run it setuid to exim instead of setuid to root. See section 52.3 for a general discussion about the advantages and disadvantages of running without root privilege.