Lunarpages Web Hosting Forum

Author Topic: How-to: Train SpamAssassin  (Read 22903 times)

Offline voman

  • Trekkie
  • **
  • Posts: 17
How-to: Train SpamAssassin
« Reply #15 on: March 05, 2005, 09:45:12 AM »
Nevermind, I had to change permission on that file to 'execute' and it works now. Thanks.

Offline kwdavids

  • Galactic Royalty
  • *****
  • Posts: 324
    • Netsmart Technologies
How-to: Train SpamAssassin
« Reply #16 on: March 05, 2005, 06:55:19 PM »
Make sure your cgi-bin directory and your sa-learn.cgi have permissions set to 755. The control panel file manager can set and display this information.
Kevin

Offline voman

  • Trekkie
  • **
  • Posts: 17
How-to: Train SpamAssassin
« Reply #17 on: March 06, 2005, 06:19:58 AM »
Now I have another question. I do not use the default mailbox for my domains but instead use an account I created - john@domain1.com, john@domain2.com, etc.

How do I train SA for spam on these mailboxes? I created the myham and myspam folders for these individual mailboxes and followed the directions above but it doesn't work. It does work for the default mailbox though.

I even went in an edited the cgi to the following (I added "vo-man.com" between the 'mail' and 'myspam' and 'myham'):

Code: [Select]
#!/usr/bin/perl

my $salearn = "/usr/bin/sa-learn" ;
$| ;

print "Content-type: text/plain\n\n" ;

print "Learning SPAM:\n" ;
print `$salearn -p /home/voman02/.spamassassin/user_prefs --mbox --spam --showdots /home/voman02/mail/vo-man.com/myspam` ;
print "\n\n" ;

print "Learning HAM:\n" ;
print `$salearn -p /home/voman02/.spamassassin/user_prefs --mbox --ham --showdots /home/voman02/mail/vo-man.com/myham` ;
print "\n\n" ;

exit ;


I am sure the mistake is here as I am not sure where to put the email address of the mailbox I would like trained. voman02 is my default login and mailbox but the one I want to train is 'john'. I hope that made sense. Any help would be appreciated.

Offline kwdavids

  • Galactic Royalty
  • *****
  • Posts: 324
    • Netsmart Technologies
How-to: Train SpamAssassin
« Reply #18 on: March 07, 2005, 05:58:13 AM »
Use the cPanel File Manager to navigate your directory structure to see where the files are. What you want to put in the script is the file name where the mail resides.

Instead of /home/voman02/mail/vo-man.com/myspam, you  probably want /home/voman02/mail/vo-man.com/john1/myspam.
Kevin

Offline brinton2

  • Newbie
  • *
  • Posts: 3
Always "learned from 0 messages"
« Reply #19 on: March 07, 2005, 07:01:18 AM »
I've read through the thread, and think everything is right... but every time I run the cgi script I get Learned from 0 message(s) (0 message(s) examined). I have a handful of test messages in my spam box. They don't get deleted either.

I'm trying to point to a single mailbox in the domain, so my vars are set as follows:

my $basepath = "/home/<account> " ;
my $configfile = "$basepath/.spamassassin/user_prefs" ;

I've edited each reference to the mailboxes as follows so it doesn't point to my main domain mailbox:
$basepath/mail/<domain>/<mailbox>/spamtraining` ;

I've also checked for errors after each command and don't catch anything.

The spamtraining box exists at that path as a file. Can anyone see what is wrong here?

Thanks in advance,
Adrian

Offline kwdavids

  • Galactic Royalty
  • *****
  • Posts: 324
    • Netsmart Technologies
How-to: Train SpamAssassin
« Reply #20 on: March 07, 2005, 07:35:00 AM »
"From 0 message(s)..." suggests that the mailbox the script is examining is not the same one that holds the spam. Perhaps instead of <mailbox> you need <user>/<mailbox> or some such thing.

The script will not delete the messages after processing them even when working normally.
Kevin

Offline voman

  • Trekkie
  • **
  • Posts: 17
How-to: Train SpamAssassin
« Reply #21 on: March 07, 2005, 07:35:20 AM »
Quote from: kwdavids
Use the cPanel File Manager to navigate your directory structure to see where the files are. What you want to put in the script is the file name where the mail resides.

Instead of /home/voman02/mail/vo-man.com/myspam, you  probably want /home/voman02/mail/vo-man.com/john1/myspam.


That did it. Thanks kwdavids! Now, when training this way, does it train for all the mail that goes to vo-man.com or only for that mailbox I specify?

Also, is there a way to have messages that are marked as SPAM by SA to be automatically deleted?

Offline kwdavids

  • Galactic Royalty
  • *****
  • Posts: 324
    • Netsmart Technologies
How-to: Train SpamAssassin
« Reply #22 on: March 07, 2005, 07:48:22 AM »
It trains only for mail in the myspam folder under john1. You need to get all the spam into that folder. When I did it, I told my users to add the spam mailbox to their own email client so they could move their spam into it.

There is a straightforward way to have spam automatically deleted. You accomplish this with an email filter (cPanel | Email | Filtering). Set up a filter that says if the "Spam Assassin header" "begins with" "Yes" then "discard". Just be sure to set your spam score high enough so as not to automatically delete something good, and maintain a good whitelist for your friends or customers. Note that if you use this method to delete spam, it's not necessary to have SA set to "rewrite headers".

Our account gets about 2500 spams a day, so we find auto-delete a necessity.
Kevin

Offline brinton2

  • Newbie
  • *
  • Posts: 3
How-to: Train SpamAssassin
« Reply #23 on: March 07, 2005, 10:25:31 AM »
Quote from: kwdavids
"From 0 message(s)..." suggests that the mailbox the script is examining is not the same one that holds the spam. Perhaps instead of <mailbox> you need <user>/<mailbox> or some such thing.

The script will not delete the messages after processing them even when working normally.


Hmmmm. When I go to the path in the filesystem, I see the file related to the mailbox. It has the spam if I open the file there. However, if I try to print the file from the cgi script, it's empty. The mailbox should be the flatfile, right? I've checked for errors in the cgi as well, but no errors. I would think if the file didn't exist, it would generate an error?

Offline kwdavids

  • Galactic Royalty
  • *****
  • Posts: 324
    • Netsmart Technologies
How-to: Train SpamAssassin
« Reply #24 on: March 07, 2005, 11:30:50 AM »
Yes, mailboxes look like flat files if you display them from the file system.

You could intentionally set the mailbox path wrong and see what error message (if any) you get. I seem to recall that you don't get an error message.

One other thing. Once the message has been processed, it won't count in the number of messages from which SA learned in subsequent passes, although it will include them in the number examined.
Kevin

Offline brinton2

  • Newbie
  • *
  • Posts: 3
How-to: Train SpamAssassin
« Reply #25 on: March 07, 2005, 05:03:45 PM »
Quote from: kwdavids
Yes, mailboxes look like flat files if you display them from the file system.

You could intentionally set the mailbox path wrong and see what error message (if any) you get. I seem to recall that you don't get an error message.

One other thing. Once the message has been processed, it won't count in the number of messages from which SA learned in subsequent passes, although it will include them in the number examined.


Ok, figured it out. I had fat-fingered the $basepath by adding a space at the end. Working perfectly now! Thanks for your help.

Offline w98

  • Galactic Royalty
  • *****
  • Posts: 443
    • http://iandouglas.com
Re: How-to: Train SpamAssassin
« Reply #26 on: July 26, 2005, 06:45:50 AM »
Please check the posting that Kathleen made 'sticky' under the Email forum -- I updated the script on July 14th to automatically scan for all user mailboxes, detect whether there's a ham/spam mailbox pair in place, and scan those ... there are also parameters to the script that you can use to only run on a single user's mailbox pair, and whether or not to clear the messages out when scanning is finished.