Courier Maildrop Filtering
From MediaWiki
Contents |
Overview
- Spam comes in to the MTA
- MTA hands it to the mail sanitizer (SpamAssassin)
- SpamAssassin tags the mail with "X-Spam-Flag: YES" and hands it back the MTA
- MTA invokes Maildrop as LMTP
- Maildrop reads etc/maildroprc
- Create ~/Maildir/.Spam (if it does not exist) and deliver to ~/Maildir/.Spam
/usr/local/etc/maildroprc
Assuming that you have configured your MTA to use SpamAssassin and use maildrop for delivery, add the following recipe to your global "maildroprc"
if ( /X-Spam-Flag: YES/ )
{
`/bin/test -d $HOME/Maildir/.Spam/`
if ($RETURNCODE != 0)
{
`/usr/local/bin/maildirmake $HOME/Maildir/.Spam/`
if ($RETURNCODE==0)
{
logfile maildrop.log
log "Creating $HOME/Maildir/.Spam/"
}
else
{
logfile maildrop.log
log "Failed creating $HOME/Maildir/.Spam/"
}
}
logfile maildrop.log
to Maildir/.Spam/
}
Maildrop Log
root# tail -f /home/sonz/maildrop.log Creating /home/sonz/Maildir/.Spam Date: Thu May 22 15:02:37 2003 From: Shanker Balan <shanu@mydomain.com> Subj: $15,500 to over $650,000 in FREE Grant Money File: Maildir/.Spam (2179)
Notes
- If Maildir ~/Maildir/.Spam/ does not exist, then maildrop will create a mbox style mailbox called .Spam and deliver to that instead which breaks Courier-IMAP. The mailbox must pre-exist as a Maildir. AFAIK, Maildrop does not have the capability to create Maildirs like procmail does.
- Amavisd/SpamAssassin's "tag_level" has been set to "3" and "tag2_level" is set to "4". Also, "final_spam_destiny" is set to "D_PASS", spams are not bounced (the default is to REJECT)
- The "." in ".Spam" is to make the Maildir compatible with Courier-IMAP
- This recipe is probably very inefficient on a busy mail server and has not been tested on one (yet). I cooked this up for use on my local box.
Resources
HOWTO Install Spamassassin to work with Maildrop and the Courier Mail Server http://www.buberel.org/linux/courier-maildrop-spamassassin.php