Colin Wetherbee wrote:
As I remember, I created #Public/spam and #Public/ham, and gave them
ACLs appropriate for public
folders.
Here is the script I use to process them for amavisd-new.
#!/usr/bin/perl -w
use strict;
use Mail::IMAPClient;
use File::Temp;
my %folders=(spam=>"#Public/spam", ham=>"#Public/ham");
my $spamuser="spam_and_ham_public_user";
my $spampass="makeupyourown";
my $imap=Mail::IMAPClient->new(Server=>"localhost",
User=>$spamuser,
Password=>$spampass);
foreach my $folder (keys %folders) {
$imap->select($folders{$folder}) || die "Can not select folder $folder
for user $spamuser";
my @messages=$imap->messages;
my $start=time;
my ($learned,$examined)=(0,0);
foreach my $message (@messages) {
my $out=File::Temp->new();
$imap->message_to_file($out->filename,$message);
my $tmp_file=$out->filename;
# close($out);
my $result=`/usr/bin/sa-learn --nosync --$folder $tmp_file 2>\&1 `;
# if ($result=~/Learned tokens
from\s*(\d+)\s*message\(s\)\s*(\s*(\d+)\s*message\(s\) examined)/) {
if ($result=~/Learned tokens from\s*(\d+).*\s*(\d+)\s*message/) {
$learned+=$1; $examined+=$2;
} else {
print $result;
$examined+=0;
$learned+=0;
}
}
$imap->delete(@messages);
$imap->set_flag('\Deleted',@messages); # sometimes just deleting
didn't work.
$imap->expunge();
$imap->close;
system("sa-learn --sync");
print sprintf "Examined %d messages, learned from %d of them.\nTotal
time for processing folder %s was %d seconds\n",
$examined,$learned,$folder,time-$start;
# }
}
Hope this helps...
Greetings.
I'd like to create the per-user folders "LearnAsSpam" and "LearnAsHam"
for my users, into which they would put messages they've verified to
be either spam or ham. Then, a nightly job would come along, feed the
messages in those boxes to SpamAssassin, and delete them from the
database.
I've read that grabbing messages directly from the database (e.g. via
a Perl script) is a bad idea and difficult to implement, anyway, since
they're fragmented across several tables and rows.
So, I'm envisioning a master user/password that can access everybody's
spam/ham folders. I could log in via IMAP as that user (again, from a
Perl script), get the messages in the usual IMAP way, and process
them. Presumably, I could also add an ACL for localhost-only access,
to address the obvious security issue.
I've been scouring the web for information on how to create a master
user but haven't been able to come up with anything.
Is this the advisable way to approach this problem in the first place?
If so, what do I need to do to get that master user going?
Thanks.
Colin
_______________________________________________
DBmail mailing list
[email protected]
https://mailman.fastxs.nl/mailman/listinfo/dbmail
_______________________________________________
DBmail mailing list
[email protected]
https://mailman.fastxs.nl/mailman/listinfo/dbmail