All,

Today I came up with a very simple hack for vdelivermail to use per-user preferences for spamassassin, and also automatically filter spam into a Junk folder.

Background:

Like most of us here probably, my customers/clients often request per user preference settings for controlling spam policies. (I was currently running site-wide spam scanning for the client in question). While there are some solutions available for this, all of them seem to have significant drawbacks:

1) Use "--enable-modify-spam" option for QmailAdmin to create .qmail files piping the message to maildrop/spamc before delivery. This is probably the best solution, but it required the user to log into QmailAdmin and turn it on first. Then, if you used SQL preferences, you could use SquirrelMail's SASQL plugin to manage those preferences. The drawback is having 2 separate interfaces: one to turn on Spam Detection (defaults to off), and one to configure preferences. Also, when migrating from site-wide to per-user, you'd have to create .qmail files for all the existing users.

2) Use simscan's --enable-spamc-user option. This is handy, but has issues since scanning at the smtp level can have multiple recipients, leading to unexpected results (simscan defaults to the first recipient's preferences).

I decided to try the --enable-spamassassin option to vpopmail, available from the current CVS release. The nice thing about this is that spamassassin scanning is on by default, but the option to delete spam is OFF by default. Also, you can use vmoddomlimits and vmoduser to turn OFF scanning for a specific user. Most of my users prefer spam scanning, so I'd rather have it default to on than off, and option #1 above did not do that.

While it worked fine (after removing the -U argument), I had trouble making vdelivermail pipe the message to maildrop for filtering after spamc was called. I didn't spend too much time on it, as I got a different idea...


Solution:

I decided to bypass the actual fork to spamc in vdelivermail and instead just pipe to maildrop. This may not seem the most elegant solution, but it does solve this problem just fine for me. Plus, I had already spent time writing my maildroprc filter to handle different delivery situations. And this way, spam scanning defaulted to on, but could be turned off on a per user bases, or set the default to OFF for a domain via vmoduser/vmoddomlimits since my patch to vdelivermail still required the --enable-spamassassin option.

If anyone would like to try this, here's what you do:

Get the latest CVS release of vpopmail.
Patch vdelivermail.c with this patch: http://shupp.org/patches/vdelivermail-spam-maildrop.patch
Compile vpopmail with --enable-spamassassin
Switch spamassassin to use mysql for preferences
You could start with this maildroprc file: http://shupp.org/software/maildroprc
(NOTE:, this file assumes you have something like "add_header spam Flag _YESNOCAPS_" in local.cf, so that the X-Spam-Flag header is set - this should probably be changed to Spam-Status)
Add sasql plugin to squirrelmail to enable preference editing.


Also, this maildroprc file allows for both a master "DELETESCORE", as well as GLOBALJUNK directory in case your client says "your spam software filtered my message and then got deleted after x number days". These are easy enough to comment out if you don't want them.


Anyway, this appears to be working well. Does anyone have a better solution? Or comments on how this could be done differently?


Cheers,

Bill Shupp

Reply via email to