Virtual Users And Domains With Postfix, MailScanner, Mailwatch & MySQL On CentOS 5.1 - Page 2

Want to support HowtoForge? Become a subscriber!
 
Submitted by o.meyer (Contact Author) (Forums) on Thu, 2008-03-06 18:04. ::

7 Mailwatch

7.1 Needed Package

yum -y install php-gd

 

7.2 Get Mailwatch

Please have a look at http://mailwatch.sourceforge.net to find out which is the latest version. When I was writing this howto, it was version 1.04.

cd /tmp/
wget http://switch.dl.sourceforge.net/sourceforge/mailwatch/mailwatch-1.0.4.tar.gz
tar xvzf mailwatch-1.0.4.tar.gz

 

7.3 Mailwatch Database

First we create and populate the mailwatch database.

mysql -p < /tmp/mailwatch-1.0.4/create.sql

Next open a MySQL shell.

mysql -u root -p

Create the MySQL user for the database.

GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY '%sql_user_password%';
FLUSH PRIVILEGES;
quit;

After that we have to insert the account data from above into some files.

vi /tmp/mailwatch-1.0.4/MailWatch.pm

my($db_user) = 'mailwatch';
my($db_pass) = '%sql_user_password%';

mv /tmp/mailwatch-1.0.4/MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/

vi /var/www/html/mailscanner/conf.php.example

define(DB_USER, 'mailwatch');
define(DB_PASS, '%sql_user_password%');
define(QUARANTINE_USE_FLAG, true);

mv /var/www/html/mailscanner/conf.php.example /var/www/html/mailscanner/conf.php

vi /tmp/mailwatch-1.0.4/SQLBlackWhiteList.pm

my($db_user) = 'mailwatch';
my($db_pass) = '%sql_user_password%';

mv /tmp/mailwatch-1.0.4/SQLBlackWhiteList.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/

 

7.4 Mailwatch Web Administrator

Now open a MySQL shell with the mailwatch MySQL user.

mysql mailscanner -u mailwatch -p

Create the web admin account.

INSERT INTO users VALUES ('%web_user_username%',md5('%web_user_password%'),'%web_user_name%','A','0','0','0','0','0');
quit;

 

7.5 Mailwatch VHost

Create a vhost like this:

<VirtualHost 192.168.0.110:80>
ServerName mailwatch.example.com ServerAdmin admin@example.com DocumentRoot /var/www/html/mailscanner/
php_admin_flag short_open_tag On php_admin_flag safe_mode Off php_admin_flag register_globals Off php_admin_flag magic_quotes_gpc On php_admin_flag magic_quotes_runtime Off php_admin_flag session.auto_start 0 php_admin_flag allow_url_fopen On
LogLevel warn ErrorLog logs/mailwatch-error_log CustomLog logs/mailwatch-access_log combined
</VirtualHost>

Afterwards move the needed files for the webinterface to the right place ...

mv mailwatch-1.0.4/mailscanner/ /var/www/html/
mkdir /var/www/html/mailscanner/temp/

... and change the ownership.

chown -R apache:apache /var/www/html/mailscanner/
chown root:apache /var/www/html/mailscanner/images/ /var/www/html/mailscanner/images/cache/
chmod ug+rwx /var/www/html/mailscanner/images/ /var/www/html/mailscanner/images/cache/
chmod ug+rw /var/www/html/mailscanner/temp/

 

7.6 Spamassassin Configuration

vi /etc/MailScanner/spam.assassin.prefs.conf

Change:

#bayes_path /etc/MailScanner/bayes/bayes
# bayes_file_mode 0770

To:

bayes_path /var/spool/MailScanner/spamassassin/bayes
bayes_file_mode 0660

And modify the directory permissions:

chown postfix:apache /var/spool/MailScanner/spamassassin/ /var/spool/MailScanner/spamassassin/bayes_*
chmod g+rws /var/spool/MailScanner/spamassassin/
chmod g+rw /var/spool/MailScanner/spamassassin/bayes_*

Test the spamassassin configuration.

spamassassin -D -p /etc/MailScanner/spam.assassin.prefs.conf --lint

You should see lines like the following in the output:

dbg: config: using "/etc/MailScanner/spam.assassin.prefs.conf" for user prefs file
dbg: bayes: tie-ing to DB file R/O /var/spool/MailScanner/spamassassin/bayes_toks
dbg: bayes: tie-ing to DB file R/O /var/spool/MailScanner/spamassassin/bayes_seen
dbg: bayes: found bayes db version 3
dbg: config: score set 0 chosen.

 

7.7 GeoIP Bugfix

In order that the geoip database update in the Mailwatch webinterface will work we have to fix a little bug.

vi /var/www/html/mailscanner/geoip_update.php

Change:

dbquery("LOAD DATA INFILE '".$base.'/'.$file2."' INTO TABLE geoip_country FIELDS TERMINATED BY ',' ENCLOSED BY '\"'");

To:

dbquery("LOAD DATA LOCAL INFILE '".$base.'/'.$file2."' INTO TABLE geoip_country FIELDS TERMINATED BY ',' ENCLOSED BY '\"'");


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.