This is the eighth 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
  7. qmail + outbound DKIM

The mess822-QMAILQUEUE patch

This is not the QMAILQUEUE patch by Bruce Guenter that’s included in netqmail. When you want qmail-smtpd(8), for instance, to be able to modify or reject incoming messages by inserting a wrapper around qmail-queue(8), the QMAILQUEUE patch makes that easier.

The mess822-QMAILQUEUE patch is the exact same idea (and code), but for mess822.

If QMAILQUEUE is set in the environment, ofmipd(8) (and new-inject(1)) run that program in place of qmail-queue, allowing you to modify submitted messages in arbitrary ways, above and beyond mess822’s own rewriting features.

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

With the QMAILQUEUE patch, rather than write your own wrapper, I’d suggest using Bruce Guenter’s qmail-qfilter and writing your own filters. With this mess822-QMAILQUEUE patch, I suggest the same.

(I hope to take advantage of this patch — already included in the ofmipd SMTP AUTH patch I’m using — to tag my occasional messages to DJB’s mailing lists with Charles Cazabon’s pymsgauth, so they get posted without my manually interacting with qsecretary.)

To set QMAILQUEUE in ofmipd’s environment:

  1. Find your ofmipd(8) invocation.
  2. If it doesn’t already call env(1) to clear the environment, add that.
  3. Look for where env is called, and pass QMAILQUEUE=/path/to/your-wrapper-program-here to it.
  4. Restart your ofmipd service.

If you’re using qmail-run from pkgsrc, that’s as easy as:

  1. echo "qmailofmipd_postenv='QMAILQUEUE=/path/to/your-wrapper-program-here'" >> /etc/rc.conf
  2. /etc/rc.d/qmailofmipd restart

Here again is the mess822-QMAILQUEUE patch.