The Perfect SpamSnake - Ubuntu Jaunty Jackalope - Page 4
17. MailWatch Installation Instructions
This setup assumes you are using Apache v2.x and not Apache v1.x.
Before Starting, make sure that MailScanner is working before you continue with the MailWatch install!
*Notes for Ubuntu:
You must have a working MailScanner set-up and running copies of MySQL, Apache, and PHP. You must also have the Perl DBD-MySQL package installed for the Perl portions of MailScanner to utilize the MySQL database.
The default php.ini set should have the following set correctly, you may want to check this:
short_open_tag = On safe_mode = Off register_globals = Off magic_quotes_gpc = On magic_quotes_runtime = Off session.auto_start = 0
These will be commented out you must remove the "#" to activate them:
Download the latest MailWatch release:
17.2 Create the database
mysql -p < create.sql
*Note: you will need to modify the above as necessary for your system if you have a root password for your MySQL database (recommended!) - Debian will ask for one.
Create a MySQL user and password & Set-up MailScanner for SQL logging:
Remember the password! You need the single quotes ' to surround your password.
17.3 Edit and move MailWatch.pm
Edit MailWatch.pm and change the $db_user and $db_pass values accordingly and move MailWatch.pm:
mv MailWatch.pm /opt/MailScanner/lib/MailScanner/CustomFunctions/
17.4 Create a MailWatch Web User
mysql mailscanner -u mailwatch -p
Enter password: ******
mysql> INSERT INTO users VALUES ('username',md5('password'),'mailscanner','A','0','0','0','0','0');
17.5 Install & Configure MailWatch
From within the unpacked mailwatch directory move the directory called 'mailscanner' to /var/www/.
mv mailscanner/ /var/www/
Make a temp directory:
Check the permissions of /var/www/mailscanner/images and /var/www/images/cache - they should be ug+rwx and owned by root and in the same group as the web server user.
chown root:www-data images
Create conf.php by copying conf.php.example and edit the values to suit, you will need to set DB_USER and DB_PASS to the MySQL user and password that you created earlier.
Change these values as shown below:
define(DB_USER, 'mailwatch'); define(DB_PASS, 'password'); define(MAILWATCH_HOME, '/var/www/mailscanner'); define(MS_LIB_DIR, '/usr/lib/MailScanner/'); define(QUARANTINE_USE_FLAG, true); define(QUARANTINE_FROM_ADDR, 'email@example.com'); define(QUARANTINE_USE_SENDMAIL, true);
17.6 Set-up MailScanner
Edit /opt/MailScanner/etc/MailScanner.conf and make sure the following are set:
Quarantine User = root Quarantine Group = www-data Quarantine Permissions = 0640 Quarantine Whole Message = yes Always Looked Up Last = &MailWatchLogging Quarantine Whole Message As Queue Files = no Detailed Spam Report = yes Include Scores In SpamAssassin Report = yes
*Important: Spam Actions, High Scoring Spam Actions and No Spam Actions should also have 'store' as one of the keywords if you want to quarantine those items for bayes learning or viewing from within MailWatch.
17.7 Integrate SQL Blacklist/Whitelist (optional)
If you would like to manage the MailScanner whitelist and blacklist from within the MailWatch web interface perform the following steps.
1. Edit the MySQL connection values within the CreateList subroutine of SQLBlackWhiteList.pm to match the values you entered previously into MailWatch.pm. Both files should contain the same values. (Look for the following lines in SQLBlackWhiteList.pm and enter your own data.)
my($db_user) = 'mailwatch'; my($db_pass) = 'password';
2. Copy SQLBlackWhiteList.pm to /opt/MailScanner/lib/MailScanner/CustomFunctions/.
3. Edit MailScanner.conf and set:
Is Definitely Not Spam = &SQLWhitelist Is Definitely Spam = &SQLBlacklist
17.8 Fix to allow MailWatch to work with Postfix Inbound/Outbound Queue
Download the patch from http://www.gbnetwork.co.uk/mailscanner/files/postfixmail.tar.gz
First we need to disable the default SpamAssassin configuration file:
mv /etc/spamassassin/local.cf /etc/spamassassin/local.cf.disabled
Now let's backup the SpamAssassin configuration file in MailScanner then edit:
cp /opt/MailScanner/etc/spam.assassin.prefs.conf /opt/MailScanner/etc/spam.assassin.prefs.conf.back
Add pyzor and razor paths to the top of /opt/MailScanner/etc/spam.assassin.prefs.conf:
pyzor_options --homedir /var/lib/MailScanner/
Look for these lines and change them accordingly:
bayes_ignore_header X-YOURDOMAIN-COM-MailScanner bayes_ignore_header X-YOURDOMAIN-COM-MailScanner-SpamCheck bayes_ignore_header X-YOURDOMAIN-COM-MailScanner-SpamScore bayes_ignore_header X-YOURDOMAIN-COM-MailScanner-Information
"YOURDOMAIN-COM" should be replaced with whatever you used for "%org-name%" in the MailScanner.conf file. Leave the "X-" in place. This is the same orgname used in the MailScanner.conf above.
Edit the SpamAssassin v310.pre to enable Razor and DCC:
loadplugin Mail::SpamAssassin::Plugin::DCC loadplugin Mail::SpamAssassin::Plugin::Razor2
17.10 SpamAssassin SQL Bayes
a. You'll need the perl-DBI and perl-DBD-MySQL modules installed.
Assumptions and Variables:
SpamAssassin Bayes Database Name: sa_bayes
Create the MySQL database:
First of all, create a database on the server where you intend on storing the bayesian information.
mysql -u root -p
mysql> create database sa_bayes;
Locate the bayes_mysql.sql file:
find / -name bayes_mysql.sql
Make some changes to your spam.assassin.prefs.conf:
bayes_store_module Mail::SpamAssassin::BayesStore::SQL bayes_sql_dsn DBI:mysql:sa_bayes:localhost bayes_sql_username sa_user bayes_sql_password sa_password bayes_sql_override_username root
Make sure the following is commented:
#bayes_path /etc/MailScanner/bayes/bayes #bayes_file_mode 0660
Also add this to your crontab:
30 01 * * * /usr/bin/sa-learn --force-expire --sync -p /opt/MailScanner/etc/spam.assassin.prefs.conf