Quick and Dirty Qmail on FreeBSD

This is not meant to be a definitive guide, just a quick install for the
impatient.  If you break anything it's not my fault.

First, you'll have to get it.  It's not a port yet, so take a look at the qmail homepage 
or just follow this link for the latest version.

Qmail is rather interesting.  To get it going, you'll have to add some group
entries and some user entries.  Don't try and compile it until you've done 
this.

1.  Add to /etc/group the following:
	qmail:*:99:
	nofiles:*:98:

2.  Fire up vipw and insert the following entries:

	alias:*:8000:98::/var/qmail/alias:/nonexistent
	qmaild:*:8001:98::/var/qmail:/nonexistent
	qmaill:*:8002:98::/var/qmail:/nonexistent
	qmailp:*:8003:98::/var/qmail:/nonexistent
	qmailq:*:8004:99::/var/qmail:/nonexistent
	qmailr:*:8005:99::/var/qmail:/nonexistent
	qmails:*:8006:99::/var/qmail:/nonexistent

3.  mkdir /var/qmail

4.  Untar it in your favorite place and:

make  (it seems to guess rather well)
make man
make setup
make check
./qmail-config (this sets up this host as one that it will relay for)

5.  If you're not terribly rushed, at least browse through the FAQ 
that's included with the distribution.  It covers alot of "special" 
cases and has pointers to other software packages.

6.  Set up aliases.  Qmail does *not* use an /etc/aliases file.

In a nutshell:

cd ~alias
echo "user-to-send-to" > .qmail-alias 
or with real users:  echo "bill" > .qmail-postmaster

Don't forget all the standard aliases.

7.  Qmail REALLY wants to deliver mail to your home directory.  You
should let it.  Read INSTALL.mbox for details.

Most mailers will let you get away with altering /etc/profile and 
/etc/csh.cshrc.  Except for elm, of course.  The above document details 
the one line that must be changed before recompiling elm.  There is a hack
to use /var/mail, but you wanted Qmail, remember?

for /etc/profile:

MAIL=$HOME/Mailbox; export MAIL

for /etc/csh.cshrc:

setenv MAIL $HOME/Mailbox

8.  It's really just about installed now; there's just some tests to
see if things are going OK.  You may want to temporarily put the qmail 
bin dir in your path.  This will fire it up:

qmail-start ./Mailbox splogger qmail &

Do a ps -auxw and look for the various qmail processes.  You should see 
qmail-lspawn running as root.  Nothing else should be.

9. Try sending to your account, and to some of the aliases you set up:

echo To: accountname | /var/qmail/bin/qmail-inject

and then check to see if the mail made it to your mail spool, which is
located in your home directory (~accountname/Mailbox).

10.  Make sure qmail starts when your machine does.  Set "sendmail"
to "NO" in /etc/rc.conf or /etc/sysconfig.

11.  Move your existing sendmail out of the way and chmod a-s it while
you're at it.  Then do this to use qmail's sendmail-emulator script:

ln -s /var/qmail/bin/sendmail /usr/sbin/sendmail

12.  Add the following line to inetd.conf and then HUP inetd:

smtp            stream  tcp     nowait  qmaild  /var/qmail/bin/tcp-env  tcp-env 
/var/qmail/bin/qmail-smtpd
 
13.  Run the queue from your old sendmail (sendmail.bak -q15m) if needed.

14.  Try sending some mail from the outside world...

That's it.  Once you have it running, I highly recommend reading all the
docs that come with it, as there are some very interesting things you can
accomplish with it.  It was my choice for a MacIIx running NetBSD on
4 megs of ram because it seems to have a very small footprint compared to
sendmail...
me