Difference between revisions of "Zarafa Bayesian Learning"

From SME Server
Jump to navigationJump to search
(Zarafa Bayesian learning)
 
m (Corrected some typo's, added some info)
Line 27: Line 27:
 
   remove: --showdots
 
   remove: --showdots
  
Set proper rights on the script:
+
Set proper permissions on the script:
   chmod 550 /usr/bin/DMZS-sa-learn.pl
+
   chmod 555 /usr/bin/DMZS-sa-learn.pl
  
 
Login to Zarafa with an account that has admin rights and make two new folders LearnAsSpam and LearnAsHam under: Public folder > Public folders.
 
Login to Zarafa with an account that has admin rights and make two new folders LearnAsSpam and LearnAsHam under: Public folder > Public folders.
Line 48: Line 48:
 
   pico /etc/e-smith/templates/etc/crontab/91_SpamAssasinLearn
 
   pico /etc/e-smith/templates/etc/crontab/91_SpamAssasinLearn
  
Add the following to the template (change the execution times to your own likings):
+
Add the following to the template (change the execution times to your own likings -- [http://en.wikipedia.org/wiki/Cron Wikipedia on Cron]):
 
   # Running the Spamassasin Bayesian SPAM learning script every hour from 8:00 to 22:00 during weekdays
 
   # Running the Spamassasin Bayesian SPAM learning script every hour from 8:00 to 22:00 during weekdays
   * 8-22 * * 1-5 root /usr/bin/DMZS-sa-learn.pl
+
   0 8-22 * * 1-5 root /usr/bin/DMZS-sa-learn.pl
  
 
Make the new fragment active by expanding the template:
 
Make the new fragment active by expanding the template:

Revision as of 09:49, 23 February 2009

Zarafa Bayesian learning

This howto enables SpamAssasin Bayesian learning for Zarafa

The DMZS script (LGPL) works over IMAP. It reads the mail from two folders (LearnAsSpam and LearnAsHam) and feeds it to SpamAssasin's sa-learn. This script is implemented here in a way that it makes use of public folders in Zarafa.

Installation

 wget http://www.dmzs.com/tools/files/spam/DMZS-sa-learn.pl
 mv DMZS-sa-learn.pl /usr/bin/

Create a user-account in Zarafa for reading the public spam-folders. Replace the <MyPassword> with a proper strong password.

 zarafa-admin -c 'SpamAdmin' -p '<MyPassword>' -f 'Spam Administration Account' -e root@localhost

Now we'll edit the script and replace the Server, User and Password values. We will also have to replace two folder names throughout the script:

 pico /usr/bin/DMZS-sa-learn.pl

Replace the values so it looks like below, replace <MyPassword> for the password you have chosen in a previous step:

 my $imap = Mail::IMAPClient->new( Server=> '127.0.0.1:8143',
                                   User => 'SpamAdmin',
                                   Password => '<MyPassword>',
                                   Debug => $debug);

Throughout the script (be aware of the quotes):

 replace: 'spam'  ->  with: 'Public folders/LearnAsSpam'
 replace: 'not-spam'  ->  with: 'Public folders/LearnAsHam'
 remove: --showdots

Set proper permissions on the script:

 chmod 555 /usr/bin/DMZS-sa-learn.pl

Login to Zarafa with an account that has admin rights and make two new folders LearnAsSpam and LearnAsHam under: Public folder > Public folders. Set the permissions (right-click folder > Properties > Permission-tab) on both these new folders to:

 Spam administration account
 * Folder visible
 * Read items
 * Edit items: all
 * Delete items: all
 
 Everyone (and/or other users/groups you've added at least need:)
 * Folder visible
 * Create items
 * Edit items: none
 * Delete items: none
Important.png Note:
Dropping mail in the public 'LearnAsHam' folder may pose a privacy problem if permissions are set less restrictive as shown above!


Create a new crontab fragment:

 pico /etc/e-smith/templates/etc/crontab/91_SpamAssasinLearn

Add the following to the template (change the execution times to your own likings -- Wikipedia on Cron):

 # Running the Spamassasin Bayesian SPAM learning script every hour from 8:00 to 22:00 during weekdays
 0 8-22 * * 1-5 root /usr/bin/DMZS-sa-learn.pl

Make the new fragment active by expanding the template:

 expand-template /etc/crontab

Configuration

Bayesian learning has to be enabled and configured in SME, you can read how to do this in: E-mail - Bayesian Autolearning

Usage

Warning.png Warning:
All mail dropped in the LearnAsSpam and LearnAsHam folders will be automatically deleted !!


  • Move/copy spam messages that are delivered to your Inbox to the public LearnAsSpam folder.
  • COPY regular messages that end up in your Junk E-mail folder to the public LearnAsHam folder.

After the messages have been processed they will be deleted to save your valuable space.