-->

Previous | Table of Contents | Next

Page 109


READ_ME       conf.h        mailq.1       queue.c       stats.c

TRACEFLAGS    convtime.c    mailstats.h   readcf.c      sysexits.c

alias.c       daemon.c      main.c        recipient.c   sysexits.h

aliases       deliver.c     makesendmail  safefile.c    trace.c

aliases.0     domain.c      map.c         savemail.c    udb.c

aliases.5     envelope.c    mci.c         sendmail.0    useful.h

arpadate.c    err.c         mime.c        sendmail.8    usersmtp.c

cdefs.h       headers.c     newaliases.0  sendmail.h    util.c

clock.c       ldap_map.h    newaliases.1  sendmail.hf   version.c

Thankfully, Eric Allman and the sendmail crew have done a fantastic job of making the installation process very straightforward. To compile your new version of sendmail, simply run


[root@gonzo src]# makesendmail

and watch it run. On the 2.0.30 kernel with Red Hat 4.2, sendmail compiles without any warnings or errors.

WARNING
Before installing the new sendmail configuration, be sure to make a backup of any files that you are going to replace, especially the old sendmail daemon you have. In the event the new sendmail doesn't work for you, you will need to restore the old versions while you troubleshoot the new version.

To install the new version of sendmail, first stop the currently running daemon with the following command:


[root@gonzo src]# /etc/rc.d/init.d/sendmail.init stop

Then simply copy the new binary to its proper place:


[root@gonzo src]# cp obj.Linux*/sendmail /usr/sbin/sendmail

It is also a good idea to copy the new man pages over too:


[root@gonzo src]# cp aliases.0 /usr/man/man5/aliases.5

[root@gonzo src]# cp mailq.0 /usr/man/man1/mailq.1

[root@gonzo src]# cp newaliases.0 /usr/man/man1/newaliases.1

[root@gonzo src]# cp sendmail.0 /usr/man/man8/sendmail.8

With everything in place, you can restart the new daemon with the following:


[root@gonzo src]# /etc/rc.d/init.d/sendmail.init start

sendmail.cf—The Configuration File

Now you've got a working sendmail, but like the Wizard of Oz's Scarecrow, it's brainless. The sendmail.cf file provides sendmail with its brains, and because it's so important, this section covers it in fairly excruciating detail. Don't worry if you don't understand everything in this

Page 110

section the first time through. It will make more sense upon rereading, and after you've had a chance to play with some configuration files of your own.

sendmail's power lies in its flexibility, which comes from its configuration file, sendmail.cf. sendmail.cf statements comprise a cryptic programming language that at first glance doesn't inspire much confidence (but C language code probably didn't either the first time you saw it). However, learning the sendmail.cf language isn't very hard, and you won't have to learn the nitty-gritty details unless you plan to write a sendmail.cf from scratch—a bad idea at best. You do need to learn enough to understand and adapt the V8 sendmail configuration file templates to your site's needs.

General Form of the Configuration File

Each line of the configuration file begins with a single command character that tells the function and syntax of that line. Lines beginning with a # are comments, and blank lines are ignored. Lines beginning with a space or tab are continuations of the preceding line, although you should usually avoid continuations.

Table 7.1 shows the command characters and their functions. This table is split into three parts corresponding to the three main functions of a configuration file, which are covered later in the chapter in the section "A Functional Description of the Configuration File."

Table 7.1. sendmail.cf command characters.


Command Character Command Syntax and Example Function
# # comments are ignored. A comment line.
Always use lots of comments.
# Standard RFC822 parsing
D DX string Defines a macro X to have the string value string.
DMmailhub.gonzo.gov
C CX word1, word2, and so on. Defines a class X as word1, word2, and so on.
Cwlocalhost myuucpname
F FX/path/to/a/file Defines a class X by reading it from a file.
Fw/etc/mail/host_aliases
H H?mailerflag?name:template Defines a mail header.
H?F?From: $q

Page 111


Command Character Command Syntax and Example Function
O OX option arguments Sets option X.
Most command-line options can be set in sendmail.cf.
OL9 # sets the log level to 9.
P Pclass=nn Sets mail delivery prece- dence based on the class of the mail.
Pjunk=-100
V Vn Tells V8 sendmail the version level of the configuration file.
V3
K Kname class arguments. Defines a key file (database map).
Kuucphosts dbm /etc/mail/uucphsts
M Mname,field_1=value_1,… Defines a mailer.
Mprog,P=/bin/sh,F=lsD,A=sh -c $u
S Snn Begins a new rule set.
S22
R Rlhs rhs comment Defines a matching / rewriting rule.
R$+ $:$>22 call ruleset 22

A Functional Description of the Configuration File

A configuration file does three things. First, it sets the environment for sendmail by telling it what options you want set and the locations of the files and databases it uses.

Second, a configuration file defines the characteristics of the mailers (delivery agents or MTAs) that sendmail uses after it decides where to route a letter. All configuration files must define local and program mailers to handle delivery to users on the local host; most also define one or more SMTP mailers; and sites that must handle UUCP mail define UUCP mailers.

Third, a configuration file specifies rulesets that rewrite sender and recipient addresses and select mailers. All rulesets are user-defined, but some have special meaning to sendmail. Ruleset 0, for example, is used to select a mailer. Rulesets 0, 1, 2, 3, and 4 all have special meaning to

Page 112

sendmail and are processed in a particular order. (See the section "The S and R Operators—Rulesets and Rewriting Rules" later in this chapter.)

The following sections cover the operators in more detail, in the order in which they appear in Table 7.1.

The D Operator—Macros

Macros are like shell variables. After you define a macro's value, you can refer to it later in the configuration file, and its value will be substituted for the macro. For example, a configuration file might have many lines that mention the hypothetical mail hub, mailer.gonzo.gov. Rather than type that name over and over, you can define a macro R (for relay mailer) as follows:


DRmailer.gonzo.gov

When sendmail encounters a $R in sendmail.cf, it substitutes the string mailer.gonzo.gov.

Macro names are always single characters. Quite a few macros are defined by sendmail and shouldn't be redefined except to work around broken software. sendmail uses lowercase letters for its predefined macros. Uppercase letters can be used freely. V8 sendmail's predefined macros are fully documented in section 5.1.2 of the SIOG.

The C and F Operators—Classes

Classes are similar to macros but are used for different purposes in rewriting rules. (See "The S and R Operators—Rulesets and Rewriting Rules" later in this chapter.) As with macros, classes are named by single characters. Lowercase letters are reserved to sendmail and uppercase letters for user-defined classes. A class contains one or more words. For example, you could define a class H containing all the hosts in the local domain as follows:


CH larry moe curly

For convenience, large classes can be continued on subsequent lines. The following definition of the class H is the same as the preceding one:


CH larry

CH moe

CH curly

You can also define a class by reading its words from a file:


CF/usr/local/lib/localhosts

If the file /usr/local/lib/localhosts contains the words larry, moe, and curly, one per line, this definition is equivalent to the preceding two.

Why use macros and classes? The best reason is that they centralize information in the configuration file. In the preceding example, if you decide to change the name of the mail hub from mailer.gonzo.gov to mailhub.gonzo.gov, you have to change only the definition of the $R macro remedy, and the configuration file will work as before. If the name mailer.gonzo.gov

Previous | Table of Contents | Next