Train Bayes Filter
Question / Problem
How can I manually train the SpamAssassin Bayes filter?
Answer / Solution
The SpamAssassin Bayes filter can be trained either using the sa-learn.exe or the spamc.exe. The main difference on a Windows system is that sa-learn will run under the currents user credentials while spamc will pass the mails that shall be trained to spamd (the SpamAssassin Daemon) which then trains the mail under the user credentials of spamd. This is especially important if you run SpamD for spam filtering under a separate user account, e.g. the Windows system user account (which is the default when using SpamAssassin in a Box for example). In this case you have to use spamc for training, as using sa-learn would just train the Bayes database for the local user.
For manual training we provide a batch script which can be used to train messages in a specific folder either as spam or ham. Besides the directory where the messages that shall be learned reside, the script requires you to decide whether the messages shall be learned as spam or ham. Please note that messages must be conform to the RFC822 format in order to make the Bayes filter work properly. For converting an Outlook message into a RFC822 conform message there are several tools available. The script tries learning using spamc first - if that fails because there is no local spamd instance available, it will "fallback" to sa-learn (assuming that learning shall be done using the local user account). To use the batch script, please follow these steps:
1. Open a command line prompt (run > cmd.exe).
2. Change directory (cd) to the installation directory of SpamAssassin in a Box .
3. Execute command: trainbayes.bat
4. Follow the instructions of the batch script.
If you want to set the folder path once without having to enter it every time you can add the line
if not defined FOLDER set "Folder=Your_path_goes_here"
below the line
set /P FOLDER=
in the trainbayes.bat.