这里我们只讲SpamAssassin的简单应用,就是利用SpamAssassin的规则集把垃圾邮件标注为垃圾邮件,然后在客户端outlook用策略把带有垃圾邮件字符的邮件自动转移到垃圾邮件目录。
参看文章
CCERT中文垃圾邮件过滤规则集
(http://www.ccert.edu.cn/spam/sa/Chinese_rules.htm)
试验环境:redhat9.0
前提条件:已经安装好qmail,本文已经搭建的环境是qmail+vpopmail+igeus
1:安装SpamAssassin
安装方法1:直接通过CPAN安装
perl-MCPAN-eshell
installMail::SpamAssassin
2:自己编译安装
去http://spamassassin.apache.org下载最新版本的软件
解压后:#perlMakefile.PL
#make
#makeinstall
#进行一个spam和non-spam的测试
在spamassassin源文件目录:
spamassassin-t<sample-spam.txt>spamtest.txt
lessspamtest.txt
spamassassin-t<sample-nonspam.txt>nospamtest.txt
lessnospamtest.txt
spamtest.txt文件在主题一段中将包含"*****SPAM*****"这一行,而nospamtest.txt文件中则没有.
(默认读取/etc/mail/spamassassin/local.cf配置.)
如果make过程中报错,可以参看此文解决相关问题http://blog.5ilinux.com/archives/2005/07/spamassassin.html
3:配置local.cf文件
#vi/etc/mail/spamassassin/local.cf
#Howmanyhitsbeforeamessageisconsideredspam.
required_hits9.5
#Texttoprependtosubjectifrewrite_subjectisused
rewrite_headerSubject*****垃圾邮件*****
#Encapsulatespaminanattachment
report_safe1
#EnabletheBayessystem
use_bayes1
#EnableBayesauto-learning
bayes_auto_learn1
#Enableordisablenetworkchecks
skip_rbl_checks1
use_razor20
use_dcc0
use_pyzor0
#Mailusinglanguagesusedinthesecountrycodeswillnotbemarked
#asbeingpossiblyspaminaforeignlanguage.
ok_languagesall
#Mailusinglocalesusedinthesecountrycodeswillnotbemarked
#asbeingpossiblyspaminaforeignlanguage.
ok_localesall
关于SpamAssassin的配置文件,可参考SpamAssassin3.x配置指南(中文版)
(http://anti-spam.org.cn/references/index.php?Action=Show&ID=9)
4:下载垃圾邮件中文规则集
wget-N-P/usr/share/spamassassinwww.ccert.edu.cn/spam/sa/Chinese_rules.cf
5:qmail和SpamAssassin的结合
在SpamAssassin3.x的spamc目录下编译qmail-spamc
#cc-O-oqmail-spamcqmail-spamc.c
#install-m755qmail-spamc/var/qmail/bin
#ln-s/var/qmail/bin/qmail-queue/usr/bin/qmail-queue
编辑/etc/tcp.smtp如下
127.:allow,RELAYCLIENT=""
:allow,QMAILQUEUE="/var/qmail/bin/qmail-spamc"
然后:
tcprulestcp.smtp.cdbtcp.smtp.tmp<tcp.smtp
在编译目录spamd目录下
mvredhat-rc-script.sh/etc/rc.d/init.d/spamd
启动spamd
/etc/rc.d/init.d/spamdstart
这样SpamAssassin会根据规则集自动判断垃圾邮件,把认为潜在可能的垃圾邮件打上****垃圾邮件****的标,一目了然,至于客户端outlook怎么设置策略自动转移垃圾邮件,就不用我说了吧。