Methods to configure Sendmail as a client where all or most e-mail goes to a remote Simple Mail Transport Protocol (SMTP) server. This documentation assumes Sendmail 8.12 or higher; older versions do not have Mail Submission Agent (MSA) support, configured via the submit.cf file. Clients splitting delivery between the local system and other hosts will need to run a localhost only SMTP daemon.
The Sendmail overview diagram illustrates where the MSA fits into E-mail flow. The Sendmail Configurations page on this site contains example client, server, and proxy configurations for Sendmail.
Three possible client configurations are shown here. The no daemon option consumes the least resources, though requires crond to schedule a periodic queue run. The clientmqueue daemon option runs a daemon that drains the queue, requiring no crond runs. This option opens no network ports. The final option runs a daemon bound to the loopback interface, which allows submission of e-mail to 127.0.0.1:25 in addition to the sendmail interface.
Set a remote server for the msp FEATURE in the submit.mc configuration file, then rebuild submit.cf. Use a periodic script run under cron(8) to clean out /var/spool/clientmqueue. Message will pile up in the clientmqueue directory if the remote server is ever unavailable.
$ sudo crontab -l | grep sendmail
# sendmail clientmqueue runner
*/30 * * * * /usr/sbin/sendmail -L sm-msp-queue -Ac -q
Masquerading and other basic configuration can be done in submit.cf; more complex configuration will require a SMTP daemon.
Vendors may ship with a sendmail.cf configured to listen and run on various ports. If this is the case, consult the vendor documentation on how to disable the sendmail process, as no running daemons are required using the above method.
Set a remote server for msp as above, but run a daemon to periodically clean out clientmqueue instead of using a periodic script. Easier to setup on systems like RedHat Linux, where minimal configuration is required to start up the queue runner after submit.cf has been rebuilt.
# cat /etc/sysconfig/sendmail
# chkconfig sendmail on
# service sendmail start
Accept e-mail only on the localhost interface (via 127.0.0.1 or ::1) from local programs. This configuration is possible using my Sendmail domain-client configuration, and suits programs that can only send e-mail via SMTP. Modern vendors often configure this as the default:
$ sudo lsof -i -nP | grep :25
sendmail- 6349 root 4u IPv4 83964593 TCP 127.0.0.1:25 (LISTEN)
sendmail- 6349 root 5u IPv6 83964594 TCP [::1]:25 (LISTEN)
For laptops or other systems not connected to the network, use the deferred delivery mode, and disable queue runs by default. Then only run the queue(s) should a network connection be available.
Set the confDELIVERY_MODE definition in sendmail.mc, and ensure the sendmail daemon runs without the -q option.
The confDELIVERY_MODE definition must appear below the msp feature.
To run the queue(s), use one or both of the following, depending on whether a localhost only daemon is being used or not. The first flushes the default mail queue (/var/spool/mqueue used by sendmail.cf), and the second /var/spool/clientmqueue (configured via submit.cf).
# sendmail -q
# sendmail -Ac -q
To check whether any e-mail is stuck in the clientmqueue directory, use mailq(1) as follows.
# mailq -Ac