Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Spamassassin training
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Gayle
n00b
n00b


Joined: 20 Feb 2004
Posts: 7

PostPosted: Sun Jun 20, 2004 2:14 pm    Post subject: Spamassassin training Reply with quote

I am trying to set up a cronjob to process false positives and negatives using maildirs but have stepped out of my league :(

What I have is two directories (maildirs) that store mail spamassassin got wrong. The false positives I want to be relearnt as ham using sa-learn (easy bit) then I want them reprocessed by procmail and redelivered to the correct directory (the bit I haven't managed).

I also want spamassassin to learn the false negatives as spam and process them again so I can see whether it is filtered properly the second time round.

Any ideas?
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Sun Jun 20, 2004 2:30 pm    Post subject: Re: Spamassassin training Reply with quote

Gayle wrote:
I am trying to set up a cronjob to process false positives and negatives using maildirs but have stepped out of my league :(

What I have is two directories (maildirs) that store mail spamassassin got wrong. The false positives I want to be relearnt as ham using sa-learn (easy bit) then I want them reprocessed by procmail and redelivered to the correct directory (the bit I haven't managed).

Why ?
The fact that it was incorrectly identified can only be ascertained by a human, i.e. you.
So you already have the mail under your direct control - what would be the point of putting it through procmail again ?
Just copy the mail to the "nospam" dir and move the original to your inbox.

Gayle wrote:
I also want spamassassin to learn the false negatives as spam and process them again so I can see whether it is filtered properly the second time round.

Again - why ?
SA does not work in this way - one single learned spam message does not upset the balance so much that the same message will immediately be classified as spam on the next time through...
Just move it to your "spam" dir and forget about it... SA will do its thing, believe me.
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
Gayle
n00b
n00b


Joined: 20 Feb 2004
Posts: 7

PostPosted: Sun Jun 20, 2004 2:45 pm    Post subject: Re: Spamassassin training Reply with quote

adaptr wrote:
Why ?
The fact that it was incorrectly identified can only be ascertained by a human, i.e. you.
So you already have the mail under your direct control - what would be the point of putting it through procmail again ?
Just copy the mail to the "nospam" dir and move the original to your inbox.

Fair enough, next question though is how do I delete the copy once it's been learnt as ham? I assume it will go in the cur directory but I'm not certain on that, if so I presume rm ~/.maildir/.notspam/cur/* will do it?
Quote:

Again - why ?
SA does not work in this way - one single learned spam message does not upset the balance so much that the same message will immediately be classified as spam on the next time through...
Just move it to your "spam" dir and forget about it... SA will do its thing, believe me.

Ok, so in that case I want to sa-learn it then move it into the spam directory. I don't want the whole spam directory learning as spam automatically as I want to be sure there are no false positives in there.
Back to top
View user's profile Send private message
bin-doph
Guru
Guru


Joined: 23 May 2003
Posts: 302

PostPosted: Mon Jun 21, 2004 8:17 am    Post subject: Re: Spamassassin training Reply with quote

Gayle wrote:

Fair enough, next question though is how do I delete the copy once it's been learnt as ham? I assume it will go in the cur directory but I'm not certain on that, if so I presume rm ~/.maildir/.notspam/cur/* will do it?


:!: I would rather modify your script to process the mail, copy/move it and the remove that mail. If u glob all files you'll propably only process one false-positive and all other mails are gone... imho u should learn and move it (I do similar, works fine)

-fe
_________________
perl -e '$_=q;4a75737420616e6f74686572205065726c204861636b65720as;;for(s;s;s;s;s;s;s;s;s;s;s;s){s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
Back to top
View user's profile Send private message
fergus
Tux's lil' helper
Tux's lil' helper


Joined: 12 Feb 2003
Posts: 99

PostPosted: Sun Aug 01, 2004 11:59 pm    Post subject: Reply with quote

you may be intersted in a script i wrote a while back...

Code:

#!/usr/bin/perl -w

use Mail::Box::Manager;

#######################################
# Run Bayesian Learning system

# forget mistake folders
foreach $dir ("cur","new","tmp") {
   `sa-learn --forget ~/.maildir/.NotSpam/$dir`;
   `sa-learn --forget ~/.maildir/.NotHam/$dir`;
}

# learn standard and corrected folders
foreach $dir ("cur","new","tmp") {
   `sa-learn --no-rebuild --ham ~/.maildir/$dir`;
   `sa-learn --no-rebuild --spam ~/.maildir/.Spam/$dir`;
   `sa-learn --no-rebuild --ham ~/.maildir/.NotSpam/$dir`;
   `sa-learn --no-rebuild --spam ~/.maildir/.NotHam/$dir`;
}

# rebuild database
`sa-learn --rebuild`;

#######################################
# Move mistake messages

# Home directory
my $homedir = "$ENV{HOME}";

# Create mailbox manager
my $mgr = new Mail::Box::Manager;

# Open spam related mailboxes
my $inbox = $mgr->open(folder => "$homedir/.maildir",
   access => 'rw',remove_when_empty => 0);
my $spam = $mgr->open(folder => "$homedir/.maildir/.Spam",
   access => 'rw',remove_when_empty => 0);
my $notham = $mgr->open(folder => "$homedir/.maildir/.NotHam",
   access => 'rw',remove_when_empty => 0);
my $notspam = $mgr->open(folder => "$homedir/.maildir/.NotSpam",
   access => 'rw',remove_when_empty => 0);

# Move messages

# NotHam to Spam
if (scalar $notham->messages) {
   @msgs = $notham->messages;
   $mgr->moveMessage($spam, @msgs);
}

# NotSpam to Inbox
if (scalar $notspam->messages) {
   @msgs = $notspam->messages;
   $mgr->moveMessage($inbox, @msgs);
}

# Close mailboxes
$inbox->close;
$spam->close;
$notham->close;
$notspam->close;
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum