oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

Setting up a Site Server with Jaguar
Pages: 1, 2, 3, 4

Starting up Sendmail

First, we'll need to edit the MAILSERVER line in /etc/hostconfig so that Sendmail starts automatically.

To do this, you'll need to use a text editor, such as emacs, vi, or pico. Our directions will show pico, as it's easy to use. Enter the following command at a command line prompt:

% sudo pico /etc/hostconfig

The file will load. Use the arrow keys to navigate the file and edit the MAILSERVER line to look like the following:


Exit pico by hitting Control-X. Pico will ask you if you want to save; tell it yes and hit return to save the file.

Second, we need to edit the startup script that Mac OS X uses to launch Sendmail. This file is located in the /System/Library/StartupItems/Sendmail directory. Before editing it, though, we are going to create a copy of it so that it can be restored.

% sudo cp /System/Library/StartupItems/Sendmail/Sendmail.orig
% sudo pico /System/Library/StartupItems/Sendmail/Sendmail

You're going to need to add one line to the sendmail startup entry. Edit the file to appear as follows, the boldface section is the only thing you need to add to this file. Oh, and be careful. A mistake here can really hurt your OS installation. Double and triple check before saving the file:


# Sendmail

. /etc/rc.common

StartService ()
     if [ "${MAILSERVER:=-NO-}" = "-YES-" ]; then
         # if ! pid=$(GetPID sendmail); then
             ConsoleMessage "Starting mail services"

             # Remove junk from the outbound mail queue directory and
start up
             # the sendmail daemon. /usr/spool/mqueue is assumed here
even though
             # it can be changed in the sendmail configuration file.
             rm -f ${queue}/nf* ${queue}/lf*

                 chmod g-w / /Users
             /usr/sbin/sendmail -bd -q1h
             /usr/sbin/sendmail -C /etc/mail/ -q1h
         # fi

StopService ()
     if pid=$(GetPID sendmail); then
         ConsoleMessage "Stopping mail services"
         kill -TERM "${pid}"
         echo "sendmail is not running."

RestartService ()
     if pid=$(GetPID sendmail); then
         ConsoleMessage "Restarting mail services"
         kill -HUP "${pid}"

We have to add this extra line to Sendmail's startup script because Apple ships Mac OS X with a root directory that is writable by any user in the admin group. Presumably, this is so that people that want to install applications on their hard drive in this location can, but Sendmail really doesn't like to run with a group writable root directory. There are ways to get Sendmail to run without this change, but they all can introduce security risks that might be determintal to your sanity.

Apple's updaters also have a nasty habit of changing the permissions on this directory back to group writable. To ensure that any changes to these permissions get changed back as soon as possible, you can add an entry to root's crontab.

% sudo sh
% export EDITOR=/usr/bin/pico
% crontab -e

Edit the crontab to look like this (Replace userid with your userid on the machine):

0 * * * * chmod g-w / /Users /

Exit pico and save the file. Setting this up means that every hour, cron will fire off a job to make sure that the permissions of your root directory are set up correctly.

Quit your editing session, making sure that you save the file. Now, restart your machine to make sure that you edited the file properly. Normally, I hate to give the advice "reboot your machine," but its necessary in this case, where we want to be sure that Sendmail will start on every reboot. After your machine starts up, you can verify that Sendmail is running properly by entering in the following at the console:

% telnet localhost 25
Connected to
Escape character is '^]'.
220 ESMTP Sendmail 8.12.2/8.12.2; Sat, 10 Aug 2002 00:43:35 -0700 (PDT)
221 2.0.0 closing connection
Connection closed by foreign host.

Simply type "QUIT" to exit out. If you don't see the above, it means that something wasn't edited correctly in the /System/Library/StartupItems/Sendmail/Sendmail script. Go back and check things very carefully. If nothing else works, copy the original file back over the file you edited and try again.

Sendmail is now up and running. It will accept mail addressed to any user at the local host. fully-qualified reversed hostname. For example, on my server, Sendmail will accept any mail addressed to, but not This is a good start, and shows that the mail server isn't an "open-relay" that will possibly spread spam, but we need to do a little more configuration to allow us to accept mail to our desired hostname.

Telling Sendmail which Hostnames are Valid to Accept Mail To

To have Sendmail accept mail to your machine's hostname, all you need to do is edit the /etc/mail/local-host-names file. To do so, enter in the following command:

% sudo pico /etc/mail/local-host-names

Simply add the hostnames that you want to receive mail for, one line at a time, to this file. For example:

For this to take effect, you'll need to restart Sendmail. Instead of rebooting, we're simply going to stop and restart Sendmail. Use the following commands to do so:

% ps -ax | grep sendmail
358  ??  Ss     0:00.34 /usr/sbin/sendmail -bd -q1h
361  ??  Ss     0:00.02 /usr/sbin/sendmail -C
735 std  S+     0:00.00 grep sendmail

% sudo kill -HUP 358

In short, we are sending the HUP signal, telling Sendmail to reload its configuration. Make sure to send the HUP to the process with the -bd -q1h arguments. Now, Sendmail will accept mail for users on your machine. This mail is delivered to the file /var/mail/[username]. For example, mail on my machine is delivered to the file /var/mail/duncan.

Setting Up Aliases

You probably want to have the ability to have more than one email address for each user on your machine. For example, I like to have the email address webmaster@mymachine. To do this, we need to use NetInfo Manager to edit the aliases that are used by the system. To launch NetInfo Manager, double click on its icon in the /Applications/Utilties folder. You'll be greeted with the following window:

Screen shot.
Use NetInfo Manager to edit the aliases that are used by the system.

To add a new alias, simply:

  1. Click the lock to make changes. You'll need to use your administrator password to unlock it.
  2. Click on the aliases entry.
  3. Click the New Folder button (the leftmost one), or use the Directory - New Subdirectory menu item.
  4. In the bottom editor window, click on the value for the name entry and enter in the name of the alias, such as "webmaster."
  5. Insert a new property by using the Directory - New Property menu item.
  6. Change the name of the new property to "members" and the value to the user you want. In my case, I made this "duncan."
  7. Save your changes (Command-S, or Domain - Save Changes). You will be asked to confirm your changes.

The NetInfo Manager window should look something like this now:

Screen shot.
Mail addressed to webmaster will be delivered to duncan.

Now, any mail addressed to webmaster will be delivered to user duncan. You can add as many aliases as you want.

Obviously there's much more to Sendmail than I have time to cover today. However, I've given you enough to get set up a site server. A more advanced article on using the advanced configuration options of Sendmail on Mac OS X is in the works and will show up here on the Mac DevCenter. In the meantime, you might want to peruse sendmail, 2nd Edition.

Pages: 1, 2, 3, 4

Next Pagearrow