Ok I got it to work i had some problems with my fechmaiil  file and i had to
recompile it a few time
this is my .fetchmailrc
poll cr.e.net proto POP3
user me.com/jh password my
mda "/usr/bin/scan.pl|/usr/local/bin/dbmail-smtp -d [EMAIL PROTECTED]"

i wrote a small script called scan.pl that based on this perl/mysql
classification filter 
http://mathforum.org/~ken/bayes/AI.tar
I had to modify this pms in a couple of place to auto increment the documents,
and i change the type from  varchar to int.

this is the scan.pl file

#!/usr/local/bin/perl5.8.2
use IO::File;
use Email::MIME;
use DBI;         # Version 1.20
use DBD::mysql;  # Version 2.09
use AI::Categorize;
use AI::Categorize::NaiveBayes;

my $holdTerminator = $/;
undef $/;
chop(my $buf = <STDIN>);
$/ = $holdTerminator;
my @lines = split /$holdTerminator/, $buf;
my $parsed = Email::MIME->new( $buf );
my $textbody = $parsed->body;
my @cleanlines =  split /$holdTerminator/, $textbody;
my $pos = 0;
$dbh = DBI->connect("DBI:mysql:bayes",root,freebsd);
my $c = new AI::Categorize($dbh);
my $myword = "";
my $neword = "";
my @result = $c-> categorize ($buf);
$dbh->disconnect;
foreach(@lines) {
chop($myword=$_);
$pos = index( $myword, "Subject:" ) ;
if ($pos == 0){
print "$myword  [$result[0]]\n";
} else {
print "$myword\n";
}
}

now i will write a small script to take all mail from  two folders bayes.spam
and bayes clean and pass it through a the perl script to classify words as
spam or clean. if anyone knows of a better idead to do this hey let me know.







Reply via email to