系統使用CentOS 5.1
郵件伺服器全系列:Postfix+Dovecot+SASL+Procmail+Postgrey+Mailscanner+Spamassassin+ClamAV+Mailscanner-mrtg+MailWatch+Openwebmail+MySPAM
MailWatch蒐集MailScanner郵件過濾的判定紀錄,可用於分析、管理規則的設定1.安裝MYSQL及相關元件
yum install mysql mysql-server mod_auth_mysql perl-DBD-MySQL
2.安裝PHP及相關元件
yum install php php-gd php-pear php-mysql php-devel
3.設定啟動服務
chkconfig httpd on
chkconfig mysqld on
4.啟動服務
service mysqld start
service httpd start
5.設定MYSQL密碼
/usr/bin/mysqladmin -u root password 'xxxxxx'
6.設定PHP
vim /etc/php.ini
short_open_tag = On
safe_mode = Off
register_globals = Off
magic_quotes_gpc = On
magic_quotes_runtime = Off
session.auto_start = 0
7.安裝MailWatch
下載http://sourceforge.net/project/showfiles.php?group_id=87163
tar -zxvf mailwatch-1.0.4.tar.gz
8.建立資料庫
cd /usr/local/src/mailwatch-1.0.4/
mysql -p < create.sql
產生mailscanner資料庫並建立資料表
9.修改MailWatch資料庫設定
vim MailWatch.pm
my($db_name) = ‘mailscanner’; (資料庫名稱)
my($db_host) = ‘localhost’; (資料庫位置)
my($db_user) = ‘root’; (使用者名稱)
my($db_pass) = ‘xxxxxx′; (使用者密碼)
10.複製設定檔
cp MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
11.新增網頁使用者
mysql mailscanner -u root -p
Enter password: ******
mysql> INSERT INTO users VALUES ('root',md5('xxxxxx'),'root','A','0','0','0','0','0');
11.設置網頁檔案
mv mailscanner /var/www/html/
12.修改網頁權限
cd /var/www/html/mailscanner
chown root:apache images
chmod ug+rwx images
chown root:apache images/cache
chmod ug+rwx images/cache
12.複製設定檔
cp conf.php.example conf.php
13.設定conf.php
vim conf.php
define(DB_TYPE, ‘mysql’);
define(DB_USER, ‘root’);
define(DB_PASS, ‘xxxxxx');
define(DB_HOST, ‘localhost’);
define(DB_NAME, ‘mailscanner’);
14.設定MailScanner
vim /etc/MailScanner/MailScanner.conf
Quarantine User = root
Quarantine Group = apache (this should be the same group as your web server)
Quarantine Permissions = 0660
Quarantine Whole Message = yes
Quarantine Whole Message As Queue Files = no
Detailed Spam Report = yes
Include Scores In SpamAssassin Report = yes
Always Looked Up Last = &MailWatchLogging
15.設定黑白名單
vim /usr/local/src/mailwatch-1.0.4/SQLBlackWhiteList.pm
my($db_name) = 'mailscanner';
my($db_host) = 'localhost';
my($db_user) = 'root';
my($db_pass) = '!Q@W#E$R';
cp /usr/local/src/mailwatch-1.0.4/SQLBlackWhiteList.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/
vim /etc/MailScanner/MailScanner.conf
Is Definitely Not Spam = &SQLWhitelist
Is Definitely Spam = &SQLBlacklist
16. 修改SpamAssassin設定
vim /etc/MailScanner/spam.assassin.prefs.conf
加入
bayes_path /etc/MailScanner/bayes/bayes
bayes_file_mode 0660
17.建立新的bayes目錄
mkdir /etc/MailScanner/bayes
chown root:apache /etc/MailScanner/bayes
chmod g+rws /etc/MailScanner/bayes
18.複製已經存在的bayes資料庫
cp /root/.spamassassin/bayes_* /etc/MailScanner/bayes
chown root:apache /etc/MailScanner/bayes/bayes_*
chmod g+rw /etc/MailScanner/bayes/bayes_*
19.測試SpamAssassin
spamassassin -D -p /etc/MailScanner/spam.assassin.prefs.conf --lint
20.重新啟動MailScanner
service MailScanner restart
備註:◎網頁中文化
◎改網頁編碼
若顯示Big5中文會出現亂碼,可以在/etc/httpd/conf.d下建立設定檔案
vim /etc/httpd/conf.d/mailwatch.conf
Alias /mailscanner /var/www/html/mailscanner
<Location /mailscanner>
Order allow,deny
allow from all
AddDefaultCharset Big5
</Location>
下集預告:郵件伺服器 Part-5:OpenWebMail