Header graphic 7 of 8



Other stuff

Other sites

I wish this site were powered by Django

March 02nd, 2008

Qmail recipes 2: Integrating qmail with nixspam and spamassassin

Filed under: qmail,Technology — jm @ 16:18

It's here! I was going to post the second part of my qmail recipes series on this weblog today, but the post got so long that I decided to publish it as an article. It's much easier to read that way. Enjoy!

February 14th, 2008

Qmail recipes 1: Forwarding mail and changing the envelope sender

Filed under: qmail,Technology — jm @ 04:29

So, I figured out a few things about qmail, vpopmail and spamassassin recently and this post will kick off a small series of the more curious things I learned. This will not be a series of "setting up qmail for standard mail" how-tos, because enough of those exist already. If you need help with setting up qmail start here, but instead of netqmail, I'd recommend John Simpson's combined qmail patch and his service-qmail-smtpd-run script. So here's the first recipe!

How do I forward emails from an account and change the envelope sender?

If you want to forward bob@test.com's emails to alice@example.com, you just put "alice@example.com" into /home/bob/.qmail and /home/bob/.qmail-default and that's it, right?

A small cave-at of this technique is that it retains the original email's envelope sender. So Bob's email addresses (bob and bob-ext) are now permanently redirected to Alice, but if someone still sends mail from Bob's email-account, Alice might receive a bounce. If that happens the forwarding might break, because in qmail's case, the envelope sender will be "#@[]" (a null-envelope sender is explicitly allowed in RFC 2821, it was intended for bounces and such). However, simple spam-checkers, like the MFCHECK-patch for qmail, will refuse envelope senders without a valid MX record. So the bounce will never get through to Alice.

As it turns out, you can avoid qmail-local's forwarding in a .qmail file and pipe the message directly into qmail-inject, providing an explicit envelope sender using the QMAILSUSER and QMAILSDOMAIN environment variables like this:

|env QMAILSUSER='forward' QMAILSHOST='test.com' \
   /var/qmail/bin/qmail-inject -a alice@example.com

The "-a" parameter is important, because it prevents qmail-inject from resending the forwarded mail to everybody listed in the email's "To:", "Cc:" and "Bcc:" headers. By using "-a" the email will only be sent to Alice.

Usually qmail-local would put the forwarded mail directly into the queue again, by bypassing this and going through qmail-inject we get more control over that process.

My qmail recipes:

03/02/2008: The second recipe is online here: Integrating qmail with nixspam and spamassassin