What Is It ?
Qmail is a modern
replacement for sendmail, written by Dan Bernstein,
who also has a web page for
qmail. qmail is a secure package. There was a $1,000 prize
for anyone who can show otherwise, which went unclaimed.
Qmail is being increasingly used by savvy and security-conscious admins
on the net. You can read more on qmail, including many other useful
patches which work with it, on the Qmail
Users' web site.
I've created a simple patch to qmail, which greatly simplifies the
use of it on dial-up hosts. Until now it was not quite ideal for
dial-up use, as it assumes the remote delivery path is always available,
which when using dial-on-demand meant by default it would dial up
straight away to deliver. This required additional software such as the
use of serialmail
, or else stopping and restarting qmail
upon connection to pick up new parameters.
With this patch, which modifies only qmail-send
, it's
possible to hold and release the remote delivery queue at will, using a
new parameter "holdremote", which will be re-read when qmail
is kicked with a SIGHUP. Thus outgoing mail can be queued as
normal, but with the holdremote flag set it will not be delivered. When
going online, arrange in your ip-up script for the parameter to be
unset, tickle qmail-send with a SIGHUP, and Roberta is your
mother's senior sibling - all queued remote mail will be immediately
rescheduled. When you go offline, set the flag again and
re-SIGHUP qmail-send
: any futher mail will be
queued for next time.
There is also a holdlocal option for symmetry and because
it virtually fell out of the code, should anyone find a use for it.
Why use this patch ?
Advantages of my method over serialmail
are:
serialmail
is additional software and configuration
beyond the basic qmail package which a user may download first time;
with my patch there is no additional software (except the patch,
obviously) or configuration.
serialmail
requires a looping call should more mail be
queued whilst online; this requires installation of still another DJB
package (daemontools). With my patch, further mail is delivered
instantly by qmail as designed, with no extra load or complexity.
- multiple
serialmail
instances can end up being run at
the same time (for instance if using diald set up by a naive admin)
unless, again, daemontools are used, thus resulting in duplicated
mail; with my patch, this cannot happen as only a qmail parameter is
changed.
- using
serialmail
to forward to a smarthost restricts
the amount of mail which can be sent at once; by sending the mail
directly it can potentially be sent faster, as the full bandwidth of
your outgoing link can be used by dispatching several mails at the
same time.
- Using a smarthost introduces an additional Single Point of Failure
into your outgoing mail. Dispatching it directly to remote hosts
using their MX records avoids this.
You do not need (though may still want) this patch if:
- you have a permanent network connection for outgoing remote mail.
- you have a dial-up link but not over IP.
- you send remote mail immediately it's queued via a dial-on-demand
dial-up IP link and are happy to continue to do so (typically applies
to people who don't pay their own phone charges :-)).
- you send remote mail to different destinations via two or more
different links (e.g. internal-to-work and net-at-large). In this
case you will require
serialmail
, which is an excellent
package for this purpose.
Download this Patch
At the time of writing, qmail is at version 1.03. There are versions of
this patch for use with both qmail 1.01 and qmail 1.03. You need the
qmail sources, to which you add this patch using the following
command:
zcat qmail-hold-<version>.pat.gz | patch -p0
Then compile and install - simple as winking !
Using the Patch
Here are some script excerpts which illustrate how I use it.
Firstly, an extract from the script which runs when my PPP link to my
ISP comes up (in my case /etc/diald/ip-up):
{ rm -f /var/qmail/control/holdremote
/usr/bin/killall -HUP qmail-send
} &
The following should be added to the PPP down script, for me that is
/etc/diald/ip-down:
{ echo 1 >/var/qmail/control/holdremote
chmod 644 /var/qmail/control/holdremote
/usr/bin/killall -HUP qmail-send
} &
Finally, in order to ensure that Qmail starts up in the held (offline)
state, you need to add the following to the script which starts it (for
me this is /etc/rc.d/init.d/sendmail.rc, in the "start" case):
echo 1 >/var/qmail/control/holdremote
chmod 644 /var/qmail/control/holdremote