Moderators: ScalixSupport, admin

leigh wrote:Hmm. Good point. Perhaps it doesn't scale as well as it could.
I'm running it on less than 25 users.
The thread referenced at the top of this one has a method of creating an mbox file from IMAP, but it also uses Mail::IMAP::Client.
The main reason I used a seperate instance for each mail is that I needed to do something different to each message, depending on which mailbox it is. Also, because I thought it would be prudent to use the "forget" function before feeding your ham into sa-learn. I also felt it was appropriate to remove the spamassassin markup first.
KKJensen wrote:I'm using FC5...in which package do i find IMAPClient? I've searched in Yum extender and it came up with some stuff for perl but it looked like a different kind of mailserver.
Does this script need to be put in any specific folder to run properly? I'm using scalix 11 b2
Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
use Mail::IMAPClient;
my $host="192.168.5.201";
my $username="sxadmin";
my $password="elisen";
my $imap = new Mail::IMAPClient( 'Server' => $host , 'User' => $username , 'Password' =>$password ) or next; #connect to server
my @folders=$imap->folders; # list folders
foreach my $folder (@folders) #look through each of them
{
if (lc($folder) eq "public folders\\junkmail\\SPAM") #Make sure we only use the right folder.
{
$imap->select($folder) or next; #Select folder
print "Folder $folder selected.\n";
my @list=$imap->messages or next; #List all messages in folder
print scalar(@list)."messages in folder.\n";
foreach my $msg (@list) #Loop over each message.
{
my @email=$imap->fetch($msg,'RFC822'); #Fetch it.
open (SALEARN,"|/usr/bin/spamassassin -d | /usr/bin/sa-learn --spam") or next; #feed it to sa-learn.
print SALEARN "$email[1]\n";
close SALEARN;
open (REPORT,"|/usr/bin/spamassassin -d | /usr/bin/spamassassin -r") or print "$!\n"; #report it
print REPORT "$email[1]";
close REPORT;
$imap->delete_message($msg) or next; #delete it
}
$imap->expunge($folder) or next; #expunge folder
}
}
Code: Select all
# time ./trainreal 0m1.060s
user 0m0.874s
sys 0m0.075s
Code: Select all
perl -MCPAN -e shell
install Mail::IMAP::Client
Why do I need to set up 4 Folders: Junk e-mail, spam, non-spam, possible spam ?
Isn't spam and junk e-mail the same??
Users browsing this forum: No registered users and 4 guests