-->
Previous Table of Contents Next


sendmail the Daemon

sendmail itself is normally configured to run on a UNIX system as a daemon in order to listen for incoming mail.


NOTE:  A daemon is a UNIX system program that runs in the background without a controlling terminal window.

When run as a daemon, unless it’s instructed not to on startup, sendmail forks and runs in the background, listening on socket 25 for incoming SMTP connections. The command to run sendmail as a daemon on a Berkeley UNIX-based system might look something like this:


/usr/lib/sendmail -bd -q30m

This command can be defined as one of the startup commands executed when the UNIX system boots. Here is a sample of a command, taken from a startup script named sendmail.init found in the /etc/rc.d/init.d directory on a Linux system:


# Start daemons.

echo -n "Starting sendmail: "

daemon sendmail -bd -q1h

echo

touch /var/lock/subsys/sendmail

;;

The -bd flag launches sendmail as a daemon and the -q1h switch instructs sendmail to check the queue once every hour. In contrast, the sample command preceding this one has the -q switch instructing sendmail to check the queue every thirty minutes.

The first action sendmail takes when it’s started is to read the /etc/sendmail.cf configuration file. The sendmail.cf and dependent configuration files are presented in the next section.

sendmail Configuration and Control Using the sendmail.cf File

Part of sendmail’s power is derived from the access provided to sendmail’s underlying configuration files. As mail messages are funneled through sendmail’s configuration files, sendmail performs all message routing functions, including parsing, forwarding, delivering, returning, and queuing.

The core of sendmail’s configuration is the sendmail.cf file. A complex configuration file read only once at sendmail’s initial run time, sendmail.cf contains three important types of information:

  Options such as operational control switches, mailer definitions, and the locations of other sendmail sub-configuration files
  Macros for use in rulesets
  Rulesets for rewriting addresses on incoming and outgoing messages


NOTE:  No one bothers to write a sendmail.cf file starting with a blank page in a text editor. If you are configuring sendmail for a new network, you can almost certainly find a sendmail.cf file that requires minimal changes. Of course, after you have a functioning mailserver, make a backup of the working configuration and put it somewhere safe.

V8 sendmail added the use of the m4 macro preprocesso, which is used to generate sendmail.cf files containing the features you select. A sendmail m4 creation file typically should be given a .mc (macro configuration) file suffix, but this is not required for the process to work. Many sample .mc scripts are supplied with the standard sendmail distributions.

For example, a minimum .mc file for a Linux workstation (without appropriate comments) could be something like this:


OSTYPE(linux)dnl

MAILER(local)dnl

These two are the only two required macros in a .mc file. You are likely to want more features, but this file—named smallest_linux.mc—could be run with the following command (assuming you are in the /usr/lib/sendmail/cf/cf directory, which is where the standard sendmail distribution places m4 files):


m4 ../m4/cf.m4 smallest_linux.mc > sendmail.cf

The following list provides a breakdown of the elements in the preceding command:

m4 Calls the m4 preprocessor
../m4/cf.m4 Identifies m4’s default configuration file
smallest_linux.mc Is the two-line macro configuration file
>sendmail.cf Specifies that output is to be placed in the sendmail.cf file

Now that you have used m4 to generate a sendmail.cf file containing exactly the features you requested, you will still need to customize the sendmail.cf file for use at your site. Using m4 for sendmail.cf generation, however, is fast and accurate. In addition to using the many m4 macros that ship with the sendmail distribution, you can also write your own as you feel necessary and include them for use.

For a quick sendmail configuration file, fill out the World Wide Web form interface to the m4 configuration tool (for V8 sendmail) at http://www.completeis.com/sendmail/sendmail.cgi. Select your desired options with the Web form, and a sendmail.cf file with the chosen options will be returned to you.


Previous Table of Contents Next