You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Marc Swanson <ms...@mswanson.com> on 2004/03/25 18:06:06 UTC

[anounce]: new script available for forwarding spam / non-spam to sa-learn

Hello list,

I've been using spamassassin for quite some time both personally and for
my customers.  I had a client that wanted a way for their users to be
able to forward emails that slipped passed the email filters so that
they could be learned as spam.

The folks responsible for spamassassin did an excellent job with the
sa-learn program to be able to train the filters with bayesian
filtering.  One of the major drawbacks however is that the users need to
have access to the mail server and the sa-learn program... not to
mention have any clue how to use it ;)


My solution was to create a separate mail user, lets say spam_user, with
two mail aliases:  is_spam and not_spam.  After setting this up, I
instructed the users to forward any spam messages they receive to the
address is_spam@theircompany.com and any incorrectly flagged spam
messages or sets of non-spam messages to not_spam@theircompany.com .

This is where my "Spam Sort" perl script comes in.  I placed an entry in
cron to call the script which then:

-logs in via IMAP as the spam_user
-checks all unread messages
-determines the type of the message by the "To:" header
-splits out each attached message in the forward and copies it as a new
message into either an is_spam or not_spam IMAP folder (mostly for
tracking purposes to see what was classified as spam/ham)
-calls sa-learn with appropriate options on the message
-sets processed messages as read
-when finished, rebuilds bayes db and permission on db files (if
necessary.. as in the case where the scrip is run as root and the files
are owned by a user).


After writing the script for them I asked and they agreed for me to post
the code here for others to use (I myself and the company I contracted
to are both big on open source).


So anyway, enough babbling, you can get the code here:

http://www.mswanson.com/?f=software/spamsort/index.html

Software comes with no warranty, blah blah blah (ooops, that's it for
babble, I promise).

Comments welcome.. obviously there are some features that would be nice
to add to the code and I may as time permits.

Hope someone finds this useful.  It worked wonders for my client (50%
spam reduction).

Best Regards

-- 
-----------------------------
Marc Swanson
MSwanson Consulting

Email:  mswanson@mswanson.com
Phone:  (603)512-1267
Fax:    (603)868-1730

http://www.mswanson.com


Re: [anounce]: new script available for forwarding spam / non-spam to sa-learn

Posted by Kiko Piris <sp...@pirispons.net>.
On 25/03/2004 at 12:06, Marc Swanson wrote:

> My solution was to create a separate mail user, lets say spam_user, with
> two mail aliases:  is_spam and not_spam.  After setting this up, I
> instructed the users to forward any spam messages they receive to the
> address is_spam@theircompany.com and any incorrectly flagged spam
> messages or sets of non-spam messages to not_spam@theircompany.com .

AFAICS, it would be better to upload both the false positives and the
false negatives to this mailboxes with, for example, imap instead of
simply forwarding the messages.

Mail clients, normally remove smtp headers when forwarding messages. And
it's better if the mail is passed to sa-learn with both body and
original headers.

Another solution would be to "bounce" the message to that other
mailboxes (not all mail clients support bouncing messages, and most of
them add some headers that are better not feeded to sa-learn).

I think that uploading messages with imap it's the best solution (many
mail clients can do that).

Another advantage is that this way, smtp server refuses mail to this
mailboxes and only the owner can upload messages there because only he
knows the imap password.

However, it has the inconvenient that you can not use the same mailbox
to both sa-learn false positives and false negatives.

I've set up something like this in my company and, given the really low
rate of false positives, I've decided to process them manually (haven't
seen a single one yet).

Cheers.

-- 
Kiko