Starting qmail is easy in principle. You run qmail-start and it starts the four communicating daemons that qmail needs. Two details complicate the situation: the default delivery instructions, and connecting the daemons to whatever you want to use for logging.
Because the daemontools package of which supervise is a part wasn't written until after qmail 1.03 was released, all of the provided startup files use splogger to send the log information to syslog. I find daemontools greatly preferable, so I primarily discuss how to set up qmail using supervise.
Qmail 1.03 comes with a selection of startup files you can use, either directly or as a starting point for a customized startup file of your own. You can find the startup files in /var/qmail/boot. None of them are usable directly with daemontools, but they're useful as templates. The differences among them only affect what happens when mail is delivered to a user who has no .qmail file, because the only difference is the string to use as a default .qmail. They include:
Which flavor of startup depends mostly on your existing mail configuration. If you use procmail, keep using it. If you have a lot of users with .forward files, use a dot-forward version. (If you only have a few .forward files, it's easier to hand-translate them into .qmail files.) I don't recommend using any of the old mail delivery programs unless you really, really want to keep delivering mail in /var/mail. For testing and usually for production, I suggest either plain home-directory mailbox delivery or procmail.
Assuming that you've installed and started
daemontools as suggested earlier in this chapter, you now must create
a pair of
directories for qmail. I use
/var/qmail/supervise/qmail-send/log to be
consistent with the widely used qmail setup instructions at
Create them like this (as the super-user, which is why the following
command lines start with a
# mkdir /var/qmail/supervise/qmail-send # mkdir /var/qmail/supervise/qmail-send/log # chown root /var/qmail/supervise/qmail-send /var/qmail/supervise/qmail-send/log # mkdir /var/qmail/supervise/qmail-send/log/main # chown qmaill /var/qmail/supervise/qmail-send/log/main
Then create run files in both the main qmail and log directories, as in Example 4-1.
Example 4-1. qmail run
1. #!/bin/sh 2. 3. limit open 1000 4. limit maxproc 100 5. 6. exec env - PATH="/var/qmail/bin:$PATH" \ 7. qmail-start ./Mailbox
commands on lines
3 and 4 ensure that qmail can run many deliveries in parallel. Set
maxproc to be larger than the number of parallel
remote deliveries permitted. (By default the number of deliveries is
20, but you'll probably want to increase it unless
you have a very slow or overloaded network connection, or handle a
very small amount of mail.) Also set
open, the per
process open-file limit, to be at least twice the greater of the
number of simultaneous local or remote deliveries permitted, because
qmail-rspawn use two pipes per delivery
subprocess. Then the
command on line 6 clears out the
environment, sets PATH to a known value, and runs
qmail-start. The argument to
qmail-start is copied from the example in
/var/qmail/boot/home to default deliveries to
Mailbox in a user's home
directory. (You can copy the startup command from one of the other
example files, such as boot/proc.)
Also create log/run to start up the logging process, as in Example 4-2.
command switches to the
qmail log pseudo-user, then runs multilog to store
qmail's output into rotating log files. The
arguments say to prefix each line with a time stamp, and to create
log files of up to 4 MB in the subdirectory
# chmod +x /var/qmail/supervise/qmail-send/run # chmod +x /var/qmail/supervise/qmail-send/log/run
Be sure the initial
#!/bin/sh line is present in
each of the scripts so they are self-running.
# ln -s /var/qmail/supervise/qmail-send /service
Assuming you have svscan running, within a few seconds of making the line, qmail will start. Look at the log file /var/qmail/supervise/qmail-send/log/main/current to be sure. It should contain a line similar to this:
status: local 0/10 remote 0/20
$ /var/qmail/bin/qmail-inject To:
memy first qmail message ^D
(Use your own username instead of
course.) The log file should now contain lines logging the local
new msg 175283 info msg 175283: bytes 230 from <email@example.com> qp 5524 uid 100 starting delivery 1: msg 175283 to local firstname.lastname@example.org status: local 1/10 remote 0/20 delivery 2: success: did_0+0+1/ status: local 0/10 remote 0/20 end msg 175283
Your file Mailbox should contain the message. If not, the log should contain evidence of the problem, which is usually files or directories not created with the correct owner or permissions.
Now try a message to a nonexistent address:
$ /var/qmail/bin/qmail-inject To: baduser oops ^D
new msg 175283 info msg 175283: bytes 212 from <email@example.com> qp 5690 uid 100 starting delivery 1: msg 175283 to local firstname.lastname@example.org status: local 1/10 remote 0/20 delivery 1: failure: Sorry,_no_mailbox_here_by_that_name._(#5.1.1)/ status: local 0/10 remote 0/20 bounce msg 175283 qp 5695 end msg 175283 new msg 175284 info msg 175284: bytes 746 from <> qp 5695 uid 124 starting delivery 2: msg 175284 to local email@example.com status: local 1/10 remote 0/20 delivery 2: success: did_0+0+1/ status: local 0/10 remote 0/20 end msg 175284
Finally, try a test message to a mailbox on a remote system. If you don't have a remote mailbox handy, use the author's autoresponder at firstname.lastname@example.org. (It will send a response message telling you how clever you were to write to it, with a blurb for my books.)
$ /var/qmail/bin/qmail-inject To: email@example.com boing ^D
The logs show the remote delivery, including the IP address of the remote system and the remote system's response:
new msg 175283 info msg 175283: bytes 223 from <firstname.lastname@example.org> qp 6808 uid 100 starting delivery 3: msg 175283 to remote email@example.com status: local 0/10 remote 1/20 delivery 3: success: 22.214.171.124_accepted_message./Remote_host_said:_250_ok_ 993021663_qp_16918/ status: local 0/10 remote 0/20 end msg 175283
If all three of these tests work, you have correctly installed qmail. Congratulations!
# svc -td /service/qmail-send
If there are deliveries in progress, qmail will wait for them to
finish or time out. Then it exits. Use
svc -u to
bring qmail back up.