十四、配置dspam--EXTMAIL

1、安装dspam

Dspam的配置主要参考《Dspam+Amavis-new+SA-Clamav for EMOS》

链接: http://www.extmail.org/forum/viewthread.php?tid=10393&extra=&page=1

 

shell

# yum install dspam-mysql 2、导入 DSPAM 训练库

shell

# cd /root/
# wget http://www.extmail.org/download/misc/dspam/dspam-trained-data.sql.gz
# gzip -d dspam-trained-data.sql.gz
# rm -rf /var/lib/mysql/dspam/ (备注:如果没有dspam的库,可以不用执行)
# mysql -u root -p -e “create database dspam”
# mysql -u root -p -e “grant all on dspam.* to dspam@localhost identified by ‘dspam’”
# mysql -u dspam -p dspam dspam < /root/dspam-trained-data.sql

DSPAM的token数据库的定时清理:

 

shell

# crontab -e

加入以下内容:

0 0 * * * /usr/bin/mysql -u dspam -p'dspam' dspam < /usr/share/dspam/sql/mysql/purge.sql0 0 * * * /usr/bin/dspam_logrotate -a 30 -d /var/spool/dspam/data3、配置 dspam.conf 文件

shell

# vi /etc/dspam/dspam.conf

变动内容如下:

DeliveryHost 127.0.0.1DeliveryPort 10024DeliveryIdent localhostDeliveryProto SMTPTrust extmailPreference "signatureLocation=headers" # 'message' or 'headers'Preference "showFactors=off"MySQLUIDInSignature onMySQLServer /var/lib/mysql/mysql.sockMySQLUser dspamMySQLPass dspamMySQLDb dspamMySQLCompress trueMySQLConnectionCache 10ServerPort 10028ServerQueueSize 32ServerPID /var/spool/dspam/dspamd.pidServerMode autoServerPass.Relay1 "secret"ServerParameters "--user extmail --deliver=innocent,spam"ServerIdent "localhost.localdomain"ClientHost 127.0.0.1ClientPort 10028ClientIdent "secret@Relay1"3、启动 dspam 进程

shell

# chkconfig dspamd on
# service dspamd start

查看dspam启动进程

 

shell

# ps aux |grep dspam

显示以下内容:

dspam 18407 0.0 0.5 5452 1344 pts/0 S 19:16 0:00 /usr/sbin/dspamd --daemonroot 18412 0.0 0.2 5140 668 pts/0 S+ 19:17 0:00 grep dspamd4、修改main.cf文件

shell

# vi /etc/postfix/main.cf

增加以下内容:

header_checks = regexp:/etc/postfix/dspam_header_checks

设置邮件标题过滤管理 以防止重复X-DSPAM-Signature标题,可以防止签名被报道为垃圾。这发生在当你从一个已经运行Dspam的服务器收到邮件,或被用于通过伪造的、滥发邮件来阻止你训练数据库,

 

shell

# vi /etc/postfix/dspam_header_checks

增加以下内容:

/^(X-DSPAM-.*)/ IGNORE/^(X-Spam-.*)/ IGNORE

重启postfix :

 

shell

# service postfix restart 5、编辑 amavisd.conf 文件

shell

# vi /etc/amavisd/amavisd.conf

增加以下内容:

$dspam = '/usr/bin/dspam';@spam_scanners = ( ['SpamAssassin', 'Amavis::SpamControl::SpamAssassin'], ['DSPAM', 'Amavis::SpamControl::ExtProg', $dspam, [ qw(--client --stdout --deliver=spam,innocent --mode=teft --user extmail)], ],);

SA增加DSpam插件:

 

shell

# cd /usr/lib/perl5/vendor_perl/5.8.5/Mail/SpamAssassin/Plugin
# wget http://www.extmail.org/download/misc/dspam/dspam.pm

编辑 local.cf 文件

 

shell

# cd /etc/mail/spamassassin/
# wget http://www.extmail.org/download/misc/dspam/dspam.cf
# vi local.cf

在下面增加以下内容

include dspam.cf

编辑 init.pre 文件:

 

shell

# vi init.pre

在下面增加以下内容

loadplugin Mail::SpamAssassin::Plugin::dspam

重启amavisd

 

shell

# service amavisd restart 6、增加 extmail 的垃圾邮件举报

说明:
Extmail 1.0.9正式加入垃圾邮件举报功能,主要基于(xueron)的补丁包,并进行了一定的调整,使该功能可以兼容DSPAM及Spamassassin两种内容过滤软件的训练。
Extmail1.1.1加入(stvictor)提供的spamassassin举报功能,感谢!

修改 webmail.cf

 

shell

# vi /var/www/extsuite/extmail/webmail.cf

主要变动的内容如下:

SYS_SPAM_REPORT_ON = 1SYS_SPAM_REPORT_TYPE = dspam

设置maidrop的全局过滤

 

shell

# vi /etc/maildroprc

内容如下:

# Decoder for high quality key word filtering# Author: hzqbbc <[email protected]> - ExtMail Dev TeamDECODER="/var/www/extsuite/extmail/tools/decode -v"if ((/^(From|Sender|Return-Path):.*MAILER\-DAEMON/)){ BADSENDER=1}# Custom filter and auto deliver to Junk mailbox support# need test command and other Unix command`test -f $HOME/.mailfilter && exit 1 || exit 0`# No customize filtering rulesif ( $RETURNCODE == 0 ){ if (/^X-Spam-Flag:.*YES/ || /^X-DSPAM-Result:.*Spam/) { exception { to "$HOME/Maildir/.Junk/." } }}7、配置DSPAM Web 界面

安装相关的rpm包:

 

shell

# yum install perl-GDGraph
# yum install perl-GD-Graph3d
# yum install dspam-web

创建dspam-web 认证用户:

 

shell

# cd /usr/share/dspam/webui/cgi-bin
# echo “extmail” > admins
# htpasswd -c .htpasswd extmail

输入认证密码

New password: Re-type new password: Adding password for user extmail

启动 dspam-web 守护进程

 

shell

# service dspam-webd start

这实际是启动了mini_httpd进程,查看 mini_httpd 是否启动正常:

 

shell

# ps aux |grep mini

显示以下内容:

dspam 18580 0.0 0.3 4152 820 ? Ss 20:05 0:00 mini_httpd -C /etc/dspam/webui.confroot 18582 0.0 0.2 5316 668 pts/0 S+ 20:05 0:00 grep mini

重启 apache

 

shell

# service httpd restart

访问 dspam-web

http://mail.example.com/dspam

输入你在 .htpasswd 文件中创建的用户和密码

你可能感兴趣的:(ExtMail,配置dspam,安装dspam)