Using sendmail to Receive Mail

sendmail runs in two different ways. When you send mail, a sendmail process starts, delivers your mail, and then terminates. To receive mail, sendmail runs as a persistent daemon process. The -bd option tells sendmail to run as a daemon and to listen to TCP port 25 for incoming mail. Use this option to accept incoming TCP/IP mail. Without it, your system will not collect inbound mail. As you'll see in Chapter 11, "More Mail Service," many systems do not collect inbound SMTP mail. Instead, they use protocols such as POP and IMAP to move mail from the mailbox server to the mail reader. In general, however, most Linux systems are configured to run sendmail as a daemon. The code that runs the sendmail daemon in the Slackware Linux /etc/rc.d/ rc.M startup script is very straightforward:

/usr/sbin/sendmail -bd -q 15m

The code runs sendmail with the -bd and -q options. In addition to listening for inbound mail, the sendmail daemon periodically checks to see if there is mail waiting to be delivered. It's possible that a sendmail process that was started to send a message was not able to successfully deliver the mail. In that case, the process writes the message to the mail queue, and counts on the daemon to deliver it at a later time. The -q option tells the sendmail daemon how often to check the undelivered mail queue. In the Slackware example, the queue is processed every 15 minutes (-q 15m).

The code that Red Hat uses to start the sendmail daemon is found in the /etc/rc.d/init.d/sendmail script. It is more complex than the code used by Slackware because Red Hat uses script variables read from an external file to set the command-line options. The file it reads is /etc/sysconfig/ sendmail, which normally contains these two lines:

DAEMON=yes QUEUE=1h

If the variable DAEMON is equal to yes, sendmail is started with the -bd option. The QUEUE variable sets the time value of the -q option. In this case, it is one hour (1h), which is a value that I like even more than the 15 minutes used by Slackware. Don't set the -q value too low. Processing the queue too often can cause problems if the queue grows very large due to a delivery problem such as a network outage. To change the queue value on a Red Hat system, edit the /etc/ sysconfig/sendmail file.

Was this article helpful?

0 0

Post a comment