Sendmail Configuration

This page has been written to show just how complex Sendmail Configuration can get, on the other hand it is almost infinitely configurable. Bazaar Systems can with this.

 

History

Yes, even the configuration of Sendmail has a history! The configuration file for sendmail is called, would you believe, "sendmail.cf". It originally contained a few settings, like the name of the host it was running on for example, and a few tables that told sendmail how to handle email addresses, known as Rule Sets. Sendmail itself, that is the binary code, is programmed to read the configuration file when it starts up - and only then. So if a change is made to the config file (known in the trade as the "cf" file) Sendmail itself needs to be restarted in order to pick up those changes.

Eventually the cf file grew to a fairly large size, and included lots of table and lists as well as an extended set of rulesets. The result was that sendmail could take many minutes to start up, as it had to check all the settings, rulesets, and tables. An early attempt to speed up the start up was to pre-parse the cf file into a format Sendmail could pretty much read directly into memory: this was know as a "frozen config" file and used the suffix sendmail.fc. It is rarely seen nowadays as it caused confusion: you could change the config, restart sendmail, and find no difference because you had forgotten to freeze the config after changing it!.

 

Rule Sets

Originally Sendmail was programmed with a small number of discreet rulesets: one was used to check the sender's address, another to check all the recipient's addresses, finally there was a "routing" ruleset that was responsible for looking at each recipient's address and working out the next hop in the delivery chain for that address. Nowadays there are many, numbered into the 90's, so the latest versions of sendmail allow rulesets to be named rather than numbered to aid configuration. Here is a typical ruleset:

############################################
### Ruleset 3 -- Name Canonicalization ###
############################################
S3

# handle null input (translate to <@> special case)
R$@ $@ <@>

# strip group: syntax (not inside angle brackets!) and trailing semicolon
R$* $: $1 <@> mark addresses
R$* < $* > $* <@> $: $1 < $2 > $3 unmark <addr>
R@ $* <@> $: @ $1 unmark @host:...
R$* :: $* <@> $: $1 :: $2 unmark node::addr
R:include: $* <@> $: :include: $1 unmark :include:...
R$* [ $* : $* ] <@> $: $1 [ $2 : $3 ] unmark IPv6 addrs
R$* : $* [ $* ] $: $1 : $2 [ $3 ] <@> remark if leading colon
R$* : $* <@> $: $2 strip colon if marked
R$* <@> $: $1 unmark
R$* ; $1 strip trailing semi
R$* < $* ; > $1 < $2 > bogus bracketed semi

# null input now results from list:; syntax
R$@ $@ :; <@>

A sendmail.cf file would normally consist of hundreds of lines like these. It has the reputation of being the single most complex configuration structure in the whole Unix world. Which is why Macros were born.

 

Macros

From around version 8 the whole structure of Sendmail configuration was redesigned using macros. These allow someone to select one or more functions from a list of preset configurations. The key here is that one is picking high level functions, like " access_db" that creates an entire database to control what addresses Sendmail will accept mail from. These macro configuration files ( they use a .mc suffix) are extremely small compared to the cf files they displaced. The cf file has not gone away though: it is created when the macro file is compiled, but now uses large areas of integrated boiler-plate sections. There is an argument that the cf files produced from macros are much larger than the old cf files they displaced; but while this may be true they are much, much easier to support. It is still occasionally necessary to "tweak" the cf file if the requirements of the system are unusual.

Here is a typical Macro configuration file:

divert(-1)
#
# Copyright (c) 1999 Chris Ray. All rights reserved.
# Copyright (c) 1998 Sendmail, Inc. All rights reserved.
# Copyright (c) 1983 Eric P. Allman. All rights reserved.
# Copyright (c) 1988, 1993
# The Regents of the University of California. All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
# This is the control file for the sendmail components
# of a client of an SMTP relay server. i.e. an ordinary system
#
# Change History
# 18/8/00 10.1 Original

divert(0)dnl
include(`/opt/sendmail-8.10.1/cf/m4/cf.m4')
VERSIONID(`@(#)client.mc 10.1.1 (ChrisRay) 18/8/2000')
define(_USE_ETC_MAIL_)dnl
define(`STATUS_FILE',`/var/spool/mail/statistics')dnl
define(`SMART_HOST', `mailhub-uk.example.net')dnl
define(`confDELIVERY_MODE',`background')dnl
define(`confLOG_LEVEL',`9')dnl
define(`confTO_QUEUERETURN',`3d')dnl
define(`confTO_QUEUEWARN',`1h')dnl
OSTYPE(solaris2)dnl
FEATURE(nouucp, reject)dnl
FEATURE(always_add_domain)dnl
FEATURE(nocanonify)dnl as DNS doesnt know about example.com

MAILER(local)dnl
MAILER(smtp)dnl


This small macro file - only 13 active lines - produces a Sendmail config file around 33 KB long.

 

The Bat Book

There are many books dedicated to the configuration of Sendmail, at least two arrive in electronic form with the product itself and are therefore updated with every new release. However the best "printed paper" book on the subject is titled simply Sendmail and known throughout the world as the bat book.

Top Return to Top of Page
About Us | Contact Us | ©2006 Bazaar Systems Limited