Previously

This is the seventh in a series of “Nifty and Minimally Invasive qmail Tricks”, following

  1. qmail + SMTP AUTH + SSL + TLS - patches
  2. qmail + badrcptto - patches
  3. qmail + NetBSD nightly maintenance
  4. qmail + IMAP-before-SMTP
  5. qmail + spam filtering
  6. qmail + SMTP AUTH + TLS redux

The QMAILREMOTE patch

When you want to wrap qmail-remote(8) with another program — for instance, to DKIM-sign outgoing mail — the QMAILREMOTE patch lets you do so by setting an environment variable.

If QMAILREMOTE is set in the environment, qmail-rspawn(8) runs that program in place of qmail-remote. Kinda like the QMAILQUEUE patch.

Your wrapper needs to adhere to the qmail-remote(8) interface, and should probably conclude its work by running the real qmail-remote binary, which — since you’re applying this patch — can stay right where it is.

To set QMAILREMOTE in the environment:

  1. Find your qmail-start(8) invocation (LWQ recommends /var/qmail/rc).
  2. Look for where PATH gets passed to env(1).
  3. Also pass QMAILREMOTE="your-wrapper-program-here".
  4. Restart qmail.

Here again is the QMAILREMOTE patch.