Koozali.org: home of the SME Server

LearnAsSpam.pl script

Offline alt-network

  • **
  • 47
  • +0/-0
    • http://www.alt-networking.com
LearnAsSpam.pl script
« on: January 04, 2007, 05:26:54 AM »
Is anyone using the LearnAsSpam.pl script. If so is it deleteing the emails from the LearnAsSpam folder?

I have is running and it is showing that it is programing the spam from the folder on the user accounts, but it is not deleteing them.

Does anyone know how to fix this?

Thanks!!!
Doyle

p.s. It is running on a sme 7.0 system.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: LearnAsSpam.pl script
« Reply #1 on: January 04, 2007, 08:37:58 AM »
Quote from: "alt-network"
Is anyone using the LearnAsSpam.pl script. If so is it deleteing the emails from the LearnAsSpam folder?

I have is running and it is showing that it is programing the spam from the folder on the user accounts, but it is not deleteing them.

Does anyone know how to fix this?

Thanks!!!
Doyle

p.s. It is running on a sme 7.0 system.
Mine has always been deleting like it should. Perhaps you could try running it from the prompt to see what it does as root user.
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
LearnAsSpam.pl script
« Reply #2 on: January 04, 2007, 11:49:14 AM »
My SA deletes spam but only if as a normal user. Admin account doesn't delete spam.
Do you have the same issue or do your normal accounts do this as well?
"It should just work" if it doesn't report it. Thanks!

Offline alt-network

  • **
  • 47
  • +0/-0
    • http://www.alt-networking.com
LearnAsSpam.pl script
« Reply #3 on: January 04, 2007, 09:15:29 PM »
When I say the messages still in the LearnAsSpam folder that is when I ran it at the command prompt. It shows that it sees the spam, but that is it.

[root@host2 ~]# perl /usr/bin/LearnAsSpam.pl
Checking for user (xxx): Doyle Glaze
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167804923.P17460Q0M525768.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806820.P21206Q0M68116.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q0M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q1M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q2M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q3M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q4M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q5M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q6M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q7M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167806878.P21318Q8M3275.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/dpg/Maildir/.LearnAsSpam/cur/1167890188.P25284Q0M475056.host2\:2,S
Result of sa-learn:
Checking for user (spam): Spam Email
Learning Spammail: /home/e-smith/files/users/spam/Maildir/.LearnAsSpam/cur/1167881462.P7084Q0M978283.host2\:2,S
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/spam/Maildir/.LearnAsSpam/cur/1167884037.14378.host2\:2,
Result of sa-learn:
Learning Spammail: /home/e-smith/files/users/spam/Maildir/.LearnAsSpam/cur/1167884260.15236.host2\:2,
Result of sa-learn:

This is what I am getting it when I run it as root....

This is the code I am running. I have made no changes to users or code:

#!/usr/bin/perl

#############################################################################
#
# This script has been developed
# by Jesper Knudsen at http://sme.swerts-knudsen.dk
#
# Revision History:
#
# January 18, 2006: Initial version
#############################################################################
#
# Each user needs ssh -  chsh -s /bin/bash <user>
#
use Sys::Hostname;

use esmith::AccountsDB;

my $hostname = hostname();

my $adb = esmith::AccountsDB->open_ro()
or die "Couldnt' open AccountsDB\n";

my @users = $adb->users;

foreach my $user (@users)
{
my $firstname = $user->prop('FirstName');
my $lastname = $user->prop('LastName');
my $key = $user->key;

printf("Checking for user (%s): %s %s\n", $key,$firstname, $lastname);

$MailDir = "/home/e-smith/files/users/" . $key . "/Maildir";
opendir(LOGDIR, $MailDir);
my $dirname = sprintf "LearnAsSpam";
my @logdirs = sort grep { /$dirname/ } readdir(LOGDIR);
closedir(LOGDIR);

foreach my $logdir (@logdirs) {

my $SpamDir = $MailDir . "/" . $logdir . "/cur/";

# printf("Checking Dir: %s\n",$SpamDir);
opendir(SPAMDIR, $SpamDir);
my @spamfiles = sort grep { /$hostname/ } readdir(SPAMDIR);
closedir(SPAMDIR);

foreach $spamfile (@spamfiles) {
my $filetolearn = $Maildir . $SpamDir . $spamfile;

$filetolearn =~ s/;/\\;/g;
$filetolearn =~ s/:/\\:/g;

printf("Learning Spammail: %s\n",$filetolearn);
my $result = `su - $key -c "/usr/bin/sa-learn --spam $filetolearn"`;
printf("Result of sa-learn: %s\n",$result);
# Now delete the file after learning
my $delete = `su - $key -c "rm -f $filetolearn"`;
# printf("Result of delete: %s\n",$delete);
}
}
}

Is ther something I am missing?

Offline sonoracomm

  • *
  • 208
  • +0/-0
    • http://www.sonoracomm.com
LearnAsSpam.pl script
« Reply #4 on: January 07, 2007, 03:32:54 AM »
I don't know the answer to your question, exactly, but I have used this howto several times with success.  There were issues with the LearnAsSpam script, but it was updated 8/06.  Files are now deleted as root and you do not have to give shell access to all users any longer.

http://www.sonoracomm.com/index.php?option=com_content&task=view&id=49&Itemid=32

The latest LearnAsSpam.pl is here:
http://mirror.contribs.org/smeserver/contribs//bread/mailstats/LearnAsSpam.pl

IHTH,

G

Offline alt-network

  • **
  • 47
  • +0/-0
    • http://www.alt-networking.com
LearnAsSpam.pl script
« Reply #5 on: January 07, 2007, 04:55:48 AM »
Thanks for your help. I had the save version but I found the mine has an error and downloading it again fixed it. Thanks......................................