Training SpamAssassin with a LearnAsSpam folder

The simplest use of IMAP is to give end-users a way to train on false positives with a LearnAsSpam folder. A cron job with a command like

/usr/local/bin/fetchmail -a -s -n --folder LearnAsSpam \
-m '$HOME/bin/sa-learn --spam' > /dev/null

will do this. More details are in the IMAP section of SingleUserUnixInstall.

Running SpamAssassin on mail in your IMAP inbox

If you have Spamassassin working, but your main mailbox is on a remote Imap folder, you can use Roger Binns' Isbg (Imap Spam Be Gone). The software can be found here, and an introduction to its use can be found at here.

SpamAssassin IMAP shared folders for groups of users

http://www.dmzs.com/tools/files/spam.phtml

There's also this docu which might work, YMMV.

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:

{{{/usr/bin/fetchmail -a -s -n -p IMAP --folder 'INBOX.Learn Spam' -m 'bash -c "/usr/bin/tee >(/usr/bin/sa-learn --spam --single \

/usr/bin/fetchmail -a -s -n -p IMAP --folder 'INBOX.Learn Ham' -m 'bash -c "/usr/bin/tee >(/usr/bin/sa-learn --ham --single \

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.

RemoteImapFolder (last edited 2009-09-20 23:16:59 by localhost)