Differences between revisions 9 and 10
Revision 9 as of 2005-04-05 00:48:37
Size: 4038
Editor: 66-120-210-133
Comment: Fixed broken link and wrapping
Revision 10 as of 2009-09-20 23:16:59
Size: 4036
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 11: Line 11:
will do this. More details are in the [wiki:Self:SingleUserUnixInstall#head-bea6b8dc4f219edd3b9976e8f922a8f1c0603125 IMAP section of SingleUserUnixInstall]. will do this. More details are in the [[SingleUserUnixInstall#head-bea6b8dc4f219edd3b9976e8f922a8f1c0603125|IMAP section of SingleUserUnixInstall]].
Line 16: Line 16:
The software can be found [http://www.rogerbinns.com/isbg/ here], and an introduction to its use can be found at [http://www.stearns.org/doc/spamassassin-setup.current.html#isbg here]. The software can be found [[http://www.rogerbinns.com/isbg/|here]], and an introduction to its use can be found at [[http://www.stearns.org/doc/spamassassin-setup.current.html#isbg|here]].
Line 28: Line 28:
There's also [http://da.andaka.org/Doku/imapspamfilter.html this] docu which might work, YMMV. There's also [[http://da.andaka.org/Doku/imapspamfilter.html|this]] docu which might work, YMMV.

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


  • DMZS-sa-learn is a perl script that reads 2 imap folders, spam & not-spam and processes them through SpamAssassin sa-learn to learn bayesian classifications.

    With many people all utilizing the same mail resources, a method for integrating the learning of all users spam that wasn't flagged properly was needed. Searching google I found several good resources on setting up & using imap and sa-learn, however all (that i have found) have the processing happen assuming Spamassassin & the imap server were located on the same machine. If you have a secured network or a large network, you will most likely have your MTA/Virus/Spam functions on separate servers from the users mail servers.

    To solve this problem I integrated perl Mail::IMAPClient into a quick script that works with sa-learn. This allows your spamassassin host to be any server and connect to one (or many, easily modified...hmm) central imap server(s) and process spam & ham classifications according to the users of those systems.

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 \

  • > /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}}}

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)