-->
Previous Table of Contents Next


sendmail Configuration Files and Their Locations

sendmail.cf is the first file that sendmail reads on startup. The sendmail.cf file contains the locations of all other subconfiguration files used by sendmail, which are listed in Table 26.2.

Table 26.2 sendmail Configuration Files

File Name and Location Description

/etc/aliases ASCII text list of defined aliases to names
/etc/aliases.db Database of aliases compiled from /etc/aliases
/etc/sendmail.hf Help file
/var/log/sendmail.st Collected statistics
/var/spool/mqueue/* Temporary files for mail queue
/var/run/sendmail.pid The process ID of the daemon

These are only the default locations of the files. Because their locations are defined within sendmail.cf, they may be set to whatever name and directory path you like.

sendmail contains far too many configuration options to list in this book. The syntax for options comes in two types: very cryptic and a bit less cryptic. In the cryptic version of option syntax, the O (capital o, not zero) command starts an option command in the sendmail.cf file. So the following two sample commands from a sendmail.cf file


O8pass8

and


O EightBitMode=pass8

perform the same function. They tell sendmail to pass 8-bit formatted data as 8 bits, and not to truncate it to 7 bits. Notice the syntax change: The single character version (O8) does not contain a space between the O and the letter signifying which option is being set, while the name version (O EightBitMode) must contain a space between the O command and the name of the option. As with all other sendmail commands, the O must be in the left-most position on the line, which is also column 1.

This restriction prevents misinterpretation of commands, such as this next line which may also be found in a sendmail.cf file:


DMMONGO

This command defines (D), a macro (M), to have the value MONGO, so that you can use $M when rewriting rules instead of typing “MONGO.” Without the restriction that a command is identified by an O in the left-most column, the O in MONGO might be interpreted as a command.

The options just presented illustrate the form of the option command for use within a configuration file. However, options may be defined either in an m4 macro file or on the command line. The command line versions of the above options would use a dash before the option, a lowercase o to indicate a single-character option command, and an uppercase O to indicate a named option command, as shown in these examples:


-o8pass8

and


-O EightBitMode=pass8

or


-O EightBitMode=pass8

sendmail Rulesets

sendmail uses rules to rewrite addresses on incoming and outgoing mail. These rules are the center of sendmail’s capability, as well as its complexity: sendmail’s rewriting rules are a specialized text-oriented programming language. Eric Allman designed sendmail so that the ruleset performs two core tasks:

  Examine each recipient’s address to determine which MDA should be used to send the message to (or nearer to) the recipient.
  Transform addresses in both the envelope and the message header to facilitate delivery or reply.

Rewriting rules are organized into rulesets. A ruleset is a subroutine or module consisting of a sequence of rules. When an address is passed to a ruleset, the subroutine passes the address to each of its rules in order. If the matching clause matches the investigated address, the rule is applied, the address is transformed, and the result is passed to the next rule. If the address does not match the current rule, the address is not transformed, and the next rule in the set is tried.

sendmail Ruleset Syntax

Each ruleset is identified by a number, and each new ruleset begins with an S in the leftmost column followed by its identifying number. Rules begin with the letter R, and are not numbered. A non-R command ends the ruleset. For example:


######################################

###   Ruleset 0 -- Parse Address   ###

######################################

S0

R$*            $: $>98 $1        handle local hacks

Rule syntax is cryptic, but fairly simple. Each rule has a left-hand side and a right-hand side. A comment portion is optional. The two sides and the optional comment are separated by tabs. The left-hand side is compared to the address as a string pattern. If the pattern matches the left-hand side, the address is transformed by the rule’s right-hand side and is passed on to the next rule.

In sendmail.cf, an octothorp (#) begins a comment line. Empty lines are ignored. The S0 defines the beginning of Ruleset 0. The R on the next line defines the beginning of a rule. The $* accepts every address that is passed to it, and the $: $>98 $1 passes the address to Ruleset 98 for further processing. The text “handle local hacks” is a comment. Because rules are tab-delimited, the comment portion does not require a comment marker (#) at the beginning.

The Core sendmail Rulesets

Several standard rulesets exist, and they may appear in any order in sendmail.cf. When sendmail reads the configuration file, it sorts the rules appropriately. A ruleset that is expected but is not present is treated as if it were present but empty. The following are the main rulesets:

  Ruleset 0 resolves an MDA by reading the address
  Ruleset 1 processes the sender’s address
  Ruleset 2 processes the recipient’s address
  Ruleset 3 preprocesses all addresses
  Ruleset 4 post-processes all addresses
  Ruleset 5 rewrites unaliased local users


Previous Table of Contents Next