[EdCert previous] [EdCert next] [EdCert top]

Configuring sendmail

sendmail's operational details are controlled by it's configuration file, sendmail.cf. Version 8.7 looks for this config file in the /etc directory. The sendmail.cf has long been renowned for sending system administrators away fleeing in panic.

Because sendmail has to read this file to find it's configuration every time it is invoked, the design of the file emphasizes easy computer parsing, rather than human sanity. So, it's not the easiest thing in the world to read and understand. Just take a look at it on any system; it has traditionally been described as looking like an explosion in a punctuation factory.

The good news is that things are much worse than they look. For one thing, there are numerous example config files distributed with the sendmail source, and one of those config files, with a bit of tweaking, will work for most people's purposes. For another, the particularly indecipherable parts of the file (the punctuation explosion parts) are actually relatively simple, once you gain an understanding of how they work. And best of all, 8.7 introduced a new method for generating config files that simplifies the process of creating a config file tremendously.

Generating A Configuration File With m4

The new configuration process in 8.7 uses m4, a macro preprocessor, to cut the configuration process down to several lines in a master configuration file (these files typically end in .mc), which is then used with m4 to generate a sendmail.cf. The idea is that the vast majority of the configuration is generic and does not need changing. All that's really needed is to turn on a few features appropriate for the system, and maybe tweak a few options. So, using a host of "boilerplate" files, m4 can distill the configuration that the administrator has to do down to what is absolutely necessary.

For the vast majority of administrators, modifying a few things in one of the sample m4 master configuration files will be adequate. You won't even have to look at the sendmail.cf, just create a short .mc file, run it through m4 to create a sendmail.cf and install the config file.

This new configuration process awesomely reduces the complexity of configuring sendmail. More complex tweaking may still be needed for strange sendmail configurations, but for the most part, a several line .mc file will be adequate.

For instance, the following is the entire .mc file used in generating the sendmail.cf for a standalone machine at Indiana University (as distributed by the Unix Workstation Support Group):

include(`../m4/cf.m4')
VERSIONID(`$Id: configuration.html,v 1.4 1996/07/24 19:45:27 brier Exp $')
OSTYPE(unknown)

FEATURE(always_add_domain)

define(`UUCP_RELAY',	`smtp:uunet.uu.net')
define(`LUSER_RELAY',	`smtp:indiana.edu')

MAILER(local)
MAILER(smtp)

The m4 macros in the .mc file look like this:

name(arg1, arg2, ..., argn)

If any of the arguments to the macro are strings, they must be surrounded by quotes. However, the quoting conventions are different from most other places. Use left and right quotes. For example:

define(`LUSER_RELAY', `smtp:indiana.edu')

Look at which characters those quotes are. It's very important to get this correct.

To generate a sendmail.cf with the above .mc file, simply issue a command similar to this from the cf/cf subdirectory of the sendmail distribution:

# m4 iu-standalone.mc >/tmp/sendmail.cf

To install the new sendmail.cf, simply copy the new it into place (backup the original first!), and restart the sendmail daemon. For convenience, many administrators keep a copy of the cf directory hierarchy at all times, so that they can easily modify .mc files and re-generate sendmail.cf files.

Essential References

For more information about generating a sendmail.cf with m4 see the README from the cf subdirectory of the sendmail source distribution. This is a pretty large document, and not all of the information is expressly necessary, so please review the following essential sections.

Please note that the "[Return to contents]" links are navigatory aids for the document as a whole (available for optional reference). Instead of using them, just use your browser's back button to return here.


Terms used: sendmail, sendmail.cf, flee, parse, m4.



[EdCert previous] [EdCert next] [EdCert top]