HOWTO setup spamassassin cgpav clamav on communigate pro
From Chaos
See this article's talk page for more information on why this article was flagged for cleanup. |
Contents |
Summary
This article outlines how to setup CommuniGate Pro to communicate with SpamAssassin and ClamAV via CGPAV on FreeBSD]. You will also need MySQL setup for SpamAssassin.
Prerequisites
1. You will need the following installed and preconfigured (in a somewhat useable state) before continuing:
- CommuniGate Pro
- MySQL
- SpamAssassin
- ClamAV
- Perl (DBI and DBD modules for so SpamAssassin can communicate with MySQL)
- Apache+PHP (So users can modify there spamassassin preferences)
2. This HOWTO also assumes that you have Apache+PHP, MySQL, SpamAssassin, ClamAV, and Communigate Pro on the same server.
Details
Initial Configuration
1. First, do a basic configuration for CommuniGate Pro and MySQL. Install SpamAssassin, and ClamAV (I installed mine from ports, so it was quite easy). Install and configure Apache+PHP.
Setup MySQL
2. Now, create a user, 'spamassassin', and a database, 'spamassassin' on your MySQL Server. Then, save the following text to a file (spamassassin.sql), and then import it using the following command:
| root@localhost:~# mysql -u root -p < spamassassin.sql |
-- Contents of spamassassin.sql
-- Use the following syntax to import it:
-- mysql -u root -p < spamassassin.sql
-- WARNING: IF YOU ALREADY HAVE A DATABASE 'spamassassin', THIS SCRIPT WILL REMOVE IT BEFORE
-- IMPORTING THE NEW DATABASE INFORMATION!!!!
--
--
DROP DATABASE spamassassin;
CREATE DATABASE spamassassin;
USE spamassassin;
CREATE TABLE userpref (
username varchar(100) NOT NULL default '',
preference varchar(30) NOT NULL default '',
value varchar(100) NOT NULL default '',
prefid int(11) NOT NULL auto_increment,
PRIMARY KEY (prefid),
KEY username (username)
) TYPE=MyISAM;
INSERT INTO userpref VALUES ('@GLOBAL', 'required_hits', '5', 1);
INSERT INTO userpref VALUES ('@GLOBAL', 'spam_level_stars', '1', 3);
INSERT INTO userpref VALUES ('@GLOBAL', 'report_header', '1', 4);
INSERT INTO userpref VALUES ('@GLOBAL', 'defang_mime', '0', 5);
INSERT INTO userpref VALUES ('@GLOBAL', 'use_terse_report', '0', 6);
INSERT INTO userpref VALUES ('@GLOBAL', 'skip_rbl_checks', '0', 7);
INSERT INTO userpref VALUES ('@GLOBAL', 'subject_tag', '### SPAM ###', 8);
INSERT INTO userpref VALUES ('@GLOBAL', 'rewrite_subject', '1', 2);
Install Perl Modules
1. There are many, many ways of installing Perl modules, from using ports to CPAN and Webmin, no one-way is right. Just get DBI and DBD installed, and you should be good to go.
Configure SpamAssassin
1. Edit the local.cf file in spamassassins configuration directory (on FreeBSD, it's in /usr/local/etc/mail/spamassassin). You'll want to put the following text in there, as well as modify any other local.cf settings you might want to:
# user_scores_dsn must be: DBI:driver:database:hostname[:port] user_scores_dsn DBI:mysql:spamassassin:localhost user_scores_sql_username spamassassin user_scores_sql_password mysecretpassword
2. You can also add the following 2 files for white and blacklisting domains. These should be placed in the same directory as local.cf
# Configuration file for blacklisted domains (50_blacklist.cf) # Syntax: blacklist_from *@*.baddomain.com blacklist_from *@*.baddomain.com
# Configuration file for whitelist domains (50_whitelist.cf) # Syntax: whitelist_from *@*.gooddomain.com whitelist_from *@*.gooddomain.com
3. You will also need to configure /etc/rc.conf to start spamd with the appropriate flags:
# SpamAssassin spamd_enable="YES" spamd_flags="-c -d -r /var/run/spamd/spamd.pid -u spamd --socketpath=/var/run/spamd/spamd"
4. Teach SpamAssassin's Bayesian filter what files are spam, and what are ham (good email). Run the following:
| root@localhost:/usr/CommuniGate/Accounts/myaccount.macnt/Spam.mdir# sa-learn --showdots --spam * |
| root@localhost:/usr/CommuniGate/Accounts/myaccount.macnt# sa-learn --showdots --mbox --ham INBOX.mbox |
Install and Configure cgpav.conf
1. Download the latest release, and follow the included instructions on how to install/compile it.
2. At this point, you'll need to do some basic configuration of cgpav.conf. I recommend using spamd's unix socket for scanning email.
Setup the Apache+PHP frontend
1. In the cgpav build directory, there is the following directory:
spam/www/php
2. This contains the PHP frontend for modifying user preferences. I copied the contents of spam/www/php to /usr/local/etc/spamconfig, and then added an Alias definition to my httpd.conf file for apache:
| root@localhost:~# mkdir /usr/local/etc/spamconfig |
| root@localhost:~# cp -r spam/www/php/* /usr/local/etc/spamconfig/ |
| root@localhost:~# vi /usr/local/etc/apache/httpd.conf |
Alias /spamconfig/ "/usr/local/etc/spamconfig/" Alias /spamconfig "/usr/local/etc/spamconfig/"
3. You'll need to modify config.php in the spamconfig/ directory, and you'll also need to add an CLI (PWD) account with rights to modify stuff in CommuniGate Pro. I'll leave this as an exercise for the reader.