Saturday, January 12, 2008

Bayesian SpamAssassin MySQL SPEC RPM

Bayesian SpamAssassin MySQL SPEC RPM

Internet links :

This documentation need to refer to files residing in BayesianMySql at
SongketMail Project Wiki. This RPM will configure Spamassassin to used
Bayesian with MySql. This document refer to bayesian-mysql version
0.0.1. This version is tested using MySql 5.0.22 and spamassassin 3.1.9.

SPEC RPM can be found here

Source to be used with SPEC RPM

Building RPM

Simple steps

(1) Copy the tar.bz2 file to /usr/src/redhat/SOURCE
(2) Copy the above spec file to /usr/src/redhat/SPEC and name it
(3) Run rpmbuild -bb /usr/src/redhat/SPEC/bayesian-mysql.spec

You need to install development packages and rpmbuild to build RPM.

This installation is using CentOS 5 as the main Linux Operating
System. Your installation may be different with Red Hat and Fedora.
Opensuse may vary need to get the right RPM name for the packages.

(1) Install Packages needed as per CentOS 5.

spamassassin, mysql, mysql-server, perl-DBI, perl-DBD-MySQL,
perl-Net-Daemon, perl-libwww-perl

or by yum

yum install spamassassin mysql mysql-server perl-DBI perl-DBD-MySQL
perl-Net-Daemon perl-libwww-perl

(2) Start the Mysql Server and create database name bayesianmysql
(login as root)

mysqladmin create bayesianmysql

Assign the user

GRANT ALL ON bayesianmysql.* to [email protected] identified by

Change the password yourpassword1234 to your own.

(3) Create the tables needed by the database.

or load the SQL file used by Bayesianmysql SPEC RPM

mysql -p -u bayesianmysql bayesianmysql < nameofsqlfile.sql

(4) Copy 2 spamassassin cf files to /etc/mail/spamassassin

Get the file name

and file name

Remember to change password as per your site or item 2.

(5) You need at least to trained spamassassin one ham and spam email
using sa-learn.

Spamassassin Public Corpus can be used if you don't have any examples.

The command :-

sa-learn --ham hamemail.txt
sa-learn --spam spamemail.txt

(6) Finishing the setup

Sync the dataset

sa-learn --sync --force-expire

Update the rules


Run the LINT test

spamassassin --lint -D

Watch the debug output from spamd and look for the following debug

debug: bayes: Database connection established
debug: bayes: Using username:

Forum and discussion


Harisfazillah Jamel for SongketMail
version 1.0
12 Jan 2008

SongketMail Project Website

No comments:

My Blog List