macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

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/sendmail.cf 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/sendmail.cf.

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/generic-darwin.mc file. The body of it looks like this:

VERSIONID(`$Id: generic-darwin.mc,v 1.3 2002/04/12 18:41:47 bbraun Exp $')
OSTYPE(darwin)dnl
DOMAIN(generic)dnl
undefine(`ALIAS_FILE')
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')
FEATURE(`smrsh',`/usr/libexec/smrsh')
FEATURE(local_procmail)
FEATURE(`virtusertable',`hash -o /etc/mail/virtusertable')dnl
FEATURE(`genericstable', `hash -o /etc/mail/genericstable')dnl 
FEATURE(`mailertable',`hash -o /etc/mail/mailertable')dnl
FEATURE(`access_db')dnl
MAILER(smtp)
MAILER(procmail)

This is much more approachable than sendmail.cf 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/generic-darwin.mc /etc/mail/config.mc

We now have a copy of the source code for the sendmail.cf 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 config.mc file to sendmail.cf looks something like:

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

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 config.mc into sendmail.cf 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/config.mc -nt /etc/mail/sendmail.cf ]
then
    echo Regenerating sendmail.cf
    m4 /usr/share/sendmail/conf/m4/cf.m4 /etc/mail/config.mc > \
        /tmp/sendmail.cf
    mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
    mv /tmp/sendmail.cf /etc/mail/sendmail.cf
    /System/Library/StartupItems/Sendmail/Sendmail restart
fi

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