SendMail

[Update: 6/20/2005. With 10.3.9 sendmail is configured to run “Automatic”. It just works w/ no configuration or fixes required. So notifications worked right away when I moved to the G3 running OS X 10.3.9.]

Sendmail quit working properly at some point. This meant notifications generated by MovableType were not being delivered. They were stuck somewhere.

This may have been caused by an Apple update of some kind. I think creating the NetInfo entry as described in on these pages is what finally solved the problem.


Getting NetInfo out of the Picture

Some of the Apple documentation on sendmail (notably, the /etc/mail/README file) implies that it’s a good idea to set a few properties in NetInfo to ensure that the sendmail binary reads its configuration from /etc/mail/sendmail.cf. So far, I’ve not had a problem with this, but in the interest of making sure that we don’t get bit by a modified sendmail binary from Apple in the future, we should go ahead and execute the commands that will modify the netinfo database:

% sudo niutil -create . /locations/sendmail

% sudo niutil -createprop . /locations/sendmail sendmail.cf /etc/mail/sendmail.cf

TIPS TO SELF:

Use Pseudo and BBEdit to edit/create files.

Login as root in all terminal commands.

Running the update script will not echo any feedback if the source file and target file are “equal”. (So change something just to make sure.)

Here are the two full pages I used…

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 > $*             $: $$| $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.

Back to Don’t Blame sendmail

In order to use the DontBlameSendmail configuration parameter with sendmail, all we need to do is add one line to the config.mc file.

Edit it to match the following. The line you need to add is bold-faced.

% sudo emacs /etc/mail/config.mc

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')

define(`confDONT_BLAME_SENDMAIL', `GroupWritableDirPathSafe')

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)

Be careful to note that the quoting around the values use both the ` and ' characters around the arguments to the define statement.. Save the file. Next we need to compile it. Execute your update script. You may need to remember to give it execute permissions (`chmod g+x /etc/mail/update') first!

% sudo ./update

Regenerating sendmail.cf

Restarting mail services

That’s all you need to do. If you followed my previous advice in Setting Up a Site Server with Jaguar and sendmail is already running, then you can remove the `chmod g-w / /Users' line in the /System/Library/StartupItems/Sendmail/Sendmail script. Be sure to edit the root crontab entry as well.

If you didn’t and don’t have sendmail running, just execute the system startup script with the start argument:

% sudo /System/Library/StartupItems/Sendmail/Sendmail start

Also, If you haven’t already done so, be sure to edit /etc/hostconfigto have sendmail startup when the system starts. If you can’t remember how to do this, refer back to the Setting Up a Site Server).

Getting NetInfo out of the Picture

Some of the Apple documentation on sendmail (notably, the /etc/mail/README file) implies that it’s a good idea to set a few properties in NetInfo to ensure that the sendmail binary reads its configuration from /etc/mail/sendmail.cf. So far, I’ve not had a problem with this, but in the interest of making sure that we don’t get bit by a modified sendmail binary from Apple in the future, we should go ahead and execute the commands that will modify the netinfo database:

% sudo niutil -create . /locations/sendmail

% sudo niutil -createprop . /locations/sendmail sendmail.cf /etc/mail/sendmail.cf

Now, we are going to take a look at several other features

that you can tweak and the various results they have.

Leave a Reply

Your email address will not be published. Required fields are marked *