Procmail + spamassassin + 'learn spam' imap?

1 post / 0 new
#1 Wed, 03/26/2008 - 12:42
maxslug

Procmail + spamassassin + 'learn spam' imap?

Has anyone integrated procmail + postfix + spamassassin inside of virtualmin and then been able to create "Learn Spam" and "Learn Ham" IMAP auto folders?

I would like to be able to integrate the last recipe from here : http://wiki.apache.org/spamassassin/RemoteImapFolder

Providing "Learn Ham" and "Learn Spam" folders that move but don't delete messages I use SpamAssassin to filter mail as it comes through my MTA, before it hands the mail off to my Cyrus IMAP server. I wanted to provide my users a way to drag false-positives and false-negatives from their Junk Mail or Inbox to another folder or folders. The mail should be picked up from that folder, learned, and then re-deposited in the "corrrect" folder, either inbox for learned-ham or junk-mail for learned-spam. For false-positives which had previously been marked up as spam, the SpamAssassin markup should be removed so the "clean" message winds up in the inbox. In the end, this turns out to be a single-line fetchmail script for each folder: [code:1] /usr/bin/fetchmail -a -s -n -p IMAP --folder 'INBOX.Learn Spam' -m 'bash -c "/usr/bin/tee >(/usr/bin/sa-learn --spam --single \ > /dev/null)|/usr/bin/spamc|/usr/lib/cyrus-imapd/deliver $LOGNAME"' mail.hughes-family.org /usr/bin/fetchmail -a -s -n -p IMAP --folder 'INBOX.Learn Ham' -m 'bash -c "/usr/bin/tee >(/usr/bin/sa-learn --ham --single \ > /dev/null)|/usr/bin/spamassassin -d|/usr/lib/cyrus-imapd/deliver $LOGNAME"' mail.hughes-family.org [/code:1] If you're using something other than Cyrus, adjust the delivery step accordingly. Also, beware of message delivery deduplication on the server -- you might lose mail if you have de-duping turned on, and because of learning the same message ends up delivered twice. I have those 2 lines in a cronjob which runs every 5 minutes. Now if spam arrives in my inbox, I just drag it to "Learn Junk" folder. It'll end up in my Junk Mail folder after fetchmail picks it up, passes it to sa-learn, then re-delivers it to cyrus tagged as spam (where a sieve script in cyrus will then file it into the right folder). For ham in my Junk Mail folder, I drag to "Learn Ham" and it'll be learned, cleaned, then deposited to my Inbox.

But I am not quite sure how to make this work with the virtual server setup.

TIP: I have an IMAP spam folder working by changing Webmin -> Servers -> Spamassassin -> Procmail Spam Delivery -> Append to Qmail-style mail directory to $HOME/Maildir/.spam

-m