oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Configuring sendmail on Jaguar
Pages: 1, 2, 3, 4, 5

Working with Configuration Files

As soon as you decide to work with sendmail's configuration files, you'll find out that there is a lot of confusing stuff in there.

Take a look at the /etc/mail/ file. The first thing you see is a header that says:

#####    DO NOT EDIT THIS FILE! Only edit the source .mc file.

Scroll down a bit further and you'll see some stuff that could only be friendly looking to an old-time Perl hacker:

# hostnames ending in class P are always canonical
R$* < @ $* $=P > $*             $: $1 < @ $2 $3 . > $4
R$* < @ $* $~P > $*             $: $&{daemon_flags} $| $1 < @ $2 $3 > $4
R$* CC $* $| $* < @ $+.$+ < $*  $: $3 < @ $4.$5 . > $6
R$* CC $* $| $*                 $: $3
# pass to name server to make hostname canonical
R$* $| $* < @ $* > $*           $: $2 < @ $[ $3 $] > $4
R$* $| $*                       $: $2

So, if you're not supposed to edit this file, and really wouldn't want to even if you should, what are you supposed to do? The answer is to ignore it. Treat it like a binary file. You don't muck about in the /bin/sh executable to use it do you? Take the same approach to /etc/mail/

Instead, we're going to see how to edit the source code for this file. Take a look at the /usr/share/sendmail/conf/cf/ file. The body of it looks like this:

VERSIONID(`$Id:,v 1.3 2002/04/12 18:41:47 bbraun Exp $')
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')dnl
FEATURE(`genericstable', `hash -o /etc/mail/genericstable')dnl 
FEATURE(`mailertable',`hash -o /etc/mail/mailertable')dnl

This is much more approachable than ever could be. This is actually a script written in the m4 macro language. m4 has been around for a while and Mac OS X ships with GNU m4 version 1.4. Luckily, it is simple enough to use without having to learn much about it. If you are interested in learning more, see the GNU m4 project page.

So, this is the source code we'll use to configure sendmail. Let's make a copy of it and put it into a place where we will remember where it is:

% sudo cp /usr/share/sendmail/conf/cf/ /etc/mail/

We now have a copy of the source code for the file in a place where we can edit it and keep track of where it is. However, even if you have a copy of the source code, you still have to know how to compile the file. In our case, the set of commands to compile the file to looks something like:

m4 /usr/share/sendmail/conf/m4/cf.m4 /etc/mail/ > /tmp/
mv /etc/mail/ /etc/mail/
mv /tmp/ /etc/mail/

Yikes! That's too much to remember. It goes against my philosophy of keeping things as simple as possible (without being too simple that is!). Luckily, I've written a little script that should help this part of working with sendmail's configuration files, as well as some of the others.

A Script to Simplify Your Life

The following script will compile into and restart sendmail so that it will notice the configuration changes. You can put it anywhere you want, I happen to have placed my copy in the /etc/mail folder so that I can find it easily. Fire up your editor of choice and cut-and-paste this in. Then, if you want to mirror what I've done, save it to /etc/mail/update. Otherwise, you might want to save it as /usr/local/bin/sendmail-update or some other fairly easy to remember location.

#! /bin/sh

if [ /etc/mail/ -nt /etc/mail/ ]
    echo Regenerating
    m4 /usr/share/sendmail/conf/m4/cf.m4 /etc/mail/ > \
    mv /etc/mail/ /etc/mail/
    mv /tmp/ /etc/mail/
    /System/Library/StartupItems/Sendmail/Sendmail restart

We're going to add a bit more to this script later. But for now, we're ready to feed sendmail a little anti-paranoia medicine.

Pages: 1, 2, 3, 4, 5

Next Pagearrow