安装 mailwatch 之前,确定系统上安装的 MailScanner 已经可以正常工作,postfix 或其他 MTA 可以正常的收发邮件,同时重要的是系统上安装好了 PHP 程序。 一、配置PHP 需要修改下 PHP 的配置文件 php.ini 里面的一些参数: vim /usr/local/webserver/php/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 二、安装配置mailwatch 1.建立 mailwatch 所需要的数据库 mailscanner mysql -uroot -p < create.sql mysql -uroot -p mysql> GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY '123456'; mysql> GRANT ALL ON mailscanner.* TO mailwatch@'127.0.0.1' IDENTIFIED BY '123456'; mysql> FLUSH PRIVILEGES; 建立web管理用户 mysql> use mailscanner; mysql> insert into users(username,password,type) values('admin',md5('123456'),'A'); 2.修改配置文件 # cd /root/mailwatch/MailScanner_perl_scripts/ # cp MailWatch.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/ # vim /usr/lib/MailScanner/MailScanner/CustomFunctions/MailWatch.pm my($db_user) = 'mailwatch'; my($db_pass) = '123456'; 黑名单、白名单设置 # cp SQLBlackWhiteList.pm /usr/lib/MailScanner/MailScanner/CustomFunctions/ my($db_user) = 'mailwatch'; my($db_pass) = '123456'; # vim /etc/MailScanner/spam.assassin.prefs.conf bayes_path /etc/MailScanner/bayes/bayes bayes_file_mode 0660 bayes_auto_learn 0 建立目录,赋予权限 # mkdir /etc/MailScanner/bayes/ # chown root:vmail /etc/MailScanner/bayes # chmod g+rws /etc/MailScanner/bayes 测试 # spamassassin -D -p /etc/MailScanner/spam.assassin.prefs.conf --lint 3.From within the unpacked mailwatch directory move the directory called 'mailscanner' to the web server's root. mv mailscanner /data/html/ Check the permissions of /data/html/mailscanner/images and /var/www/html/images/cache - they should be ug+rwx and owned by root and in the same group as the web server user # chown -R root:vmail /data/html/mailscanner/ # chmod -R ug+rwx /data/html/mailscanner/images # chmod ug+rwx images # chmod ug+rwx images/cache 添加虚拟主机 # vim /usr/local/webserver/apache/conf/extra/extmail-vhosts.conf <VirtualHost *:80> ServerName mailwatch.fresh100.com.cn DocumentRoot /data/html/mailscanner/ Errorlog /usr/local/webserver/apache/logs/mailwatch-error.log CustomLog /usr/local/webserver/apache/logs/mailwatch-access.log combined </VirtualHost> 4.修改mailwatch web配置 文件 # cp /data/html/mailscanner/conf.php.example /data/html/mailscanner/conf.php # vim /data/html/mailscanner/conf.php define('DB_USER', 'mailwatch'); define('DB_PASS', '123456'); define('MAILWATCH_HOME', '/data/html/mailscanner'); 5.修改MailScanner配置 # vim /etc/MailScanner/MailScanner.conf Quarantine User = root Quarantine Group = vmail (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 Quarantine Permissions = 0660 Always Looked Up Last = &MailWatchLogging Is Definitely Not Spam = &SQLWhitelist Is Definitely Spam = &SQLBlacklist 6.重新启动MailScanner # service MailScanner stop # service MailScanner start 日志信息如下,证明配置成功 Dec 12 10:57:11 mail MailScanner[21681]: Starting up SQL Blacklist Dec 12 10:57:11 mail MailScanner[21681]: Read 0 blacklist entries Dec 12 10:57:11 mail MailScanner[21681]: Config: calling custom init function MailWatchLogging Dec 12 10:57:11 mail MailScanner[21681]: Started SQL Logging child Dec 12 10:57:11 mail MailScanner[21681]: Config: calling custom init function SQLWhitelist Dec 12 10:57:11 mail MailScanner[21681]: Starting up SQL Whitelist Dec 12 10:57:11 mail MailScanner[21681]: Read 0 whitelist entries 三、如下测试: 白名单和黑名单,查询数据库如下: mysql> select * from blacklist; +----+-----------------+-----------------+---------------+ | id | to_address | to_domain | from_address | +----+-----------------+-----------------+---------------+ | 1 | fresh100.com.cn | fresh100.com.cn | okauto.com.cn | +----+-----------------+-----------------+---------------+ 1 row in set (0.00 sec) mysql> select * from whitelist; +----+-----------------+-----------------+-----------------------+ | id | to_address | to_domain | from_address | +----+-----------------+-----------------+-----------------------+ | 1 | fresh100.com.cn | fresh100.com.cn | service@okauto.com.cn | +----+-----------------+-----------------+-----------------------+ 1 row in set (0.00 sec) 作用为:除了账号service@okauto.com.cn 可以向fresh100.com.cn域内账号发送邮件,且不被视为垃圾邮件外。okauto.com.cn域内的其他所有账号向fresh100.com.cn域内账号发邮件,将被作为垃圾邮件处理。 |
|