SpamAssassin的简单应用

[不指定 2006/12/26 23:18 | by ipaddr ]
这里我们只讲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 -e shell
install Mail::SpamAssassin

2:自己编译安装
去http://spamassassin.apache.org下载最新版本的软件

解压后:# perl Makefile.PL
# make
# make install

# 进行一个spam和non-spam的测试
在spamassassin源文件目录:
spamassassin -t < sample-spam.txt > spamtest.txt
less spamtest.txt
spamassassin -t < sample-nonspam.txt > nospamtest.txt
less nospamtest.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

# How many hits before a message is considered spam.
required_hits           9.5

# Text to prepend to subject if rewrite_subject is used
rewrite_header Subject  *****垃圾邮件*****

# Encapsulate spam in an attachment
report_safe             1

# Enable the Bayes system
use_bayes               1

# Enable Bayes auto-learning
bayes_auto_learn        1

# Enable or disable network checks
skip_rbl_checks         1
use_razor2              0
use_dcc                 0
use_pyzor               0

# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_languages            all

# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
ok_locales              all

关于SpamAssassin的配置文件,可参考SpamAssassin 3.x 配置指南(中文版)
(http://anti-spam.org.cn/references/index.php?Action=Show&ID=9)

4:下载垃圾邮件中文规则集
wget -N -P /usr/share/spamassassin www.ccert.edu.cn/spam/sa/Chinese_rules.cf

5:qmail和SpamAssassin的结合

在SpamAssassin 3.x 的spamc 目录下编译qmail-spamc
# cc -O -o qmail-spamc qmail-spamc.c
# install -m 755 qmail-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"

然后:
tcprules tcp.smtp.cdb tcp.smtp.tmp < tcp.smtp

在编译目录spamd目录下
mv  redhat-rc-script.sh /etc/rc.d/init.d/spamd

启动spamd
/etc/rc.d/init.d/spamd start

这样SpamAssassin会根据规则集自动判断垃圾邮件,把认为潜在可能的垃圾邮件打上****垃圾邮件****的标,一目了然,至于客户端outlook怎么设置策略自动转移垃圾邮件,就不用我说了吧。

分页: 1/1 第一页 1 最后页 [ 显示模式: 摘要 | 列表 ]