首页 |  最新动态 |  产品介绍 |  购买NOD32 |  下载专区 |  联系我们
NOD32 产品下载 
试用版    商业版 
索取NOD32企业版试用授权 
NOD32全球获得之奖项
 

NOD32LMS Spamassassin

Prepared by NOD32 Hong Kong
March 2005


Introduction

Spamassassin is the most commonly used anti-spam solution for Linux Mail Servers. SpamAssassin is a flexible anti-spam solution, you can create rules yourself in system and user level. Also, it support auto-learn function to meet this fast changing world.

Here we will give a sample installation and configuration steps on Redhat (or redhat like linux) using postfix as email server.

Install SpamAssassin

There are many ways to install SpamAssassin, here we choose to install with perl CPAN (http://www.cpan.org).

Let's create a install scripts /root/install_spamd , put the following content in the file /root/install_spamd.

export LANG=C
perl -MCPAN -e'CPAN::Shell->install("Archive::Tar")'
perl -MCPAN -e'CPAN::Shell->install("Archive::Zip")'
perl -MCPAN -e'CPAN::Shell->install("Config::IniFiles")'
perl -MCPAN -e'CPAN::Shell->install("Convert::UUlib")'
perl -MCPAN -e'CPAN::Shell->install("Digest::MD5")'
perl -MCPAN -e'CPAN::Shell->install("File::MMagic")'
perl -MCPAN -e'CPAN::Shell->install("IO::String")'
perl -MCPAN -e'CPAN::Shell->install("Net::Libnet ")'
perl -MCPAN -e'CPAN::Shell->install("Convert::TNEF")'
perl -MCPAN -e'CPAN::Shell->install("Mail::SpamAssassin")'
perl -MCPAN -e'CPAN::Shell->install("Net::Server")'
perl -MCPAN -e'CPAN::Shell->install("Unicode::Map")'
perl -MCPAN -e'CPAN::Shell->install("Unicode::String")'
perl -MCPAN -e'CPAN::Shell->install("Unix::Syslog")'
perl -MCPAN -e'CPAN::Shell->install("Digest::SHA1")'
perl -MCPAN -e'CPAN::Shell->install("Digest::HMAC")'
perl -MCPAN -e'CPAN::Shell->install("Net::DNS")'
perl -MCPAN -e'CPAN::Shell->install("Net::SMTP")'
perl -MCPAN -e'CPAN::Shell->install("Net::Ident")'
perl -MCPAN -e'CPAN::Shell->install("Time::HiRes")'
perl -MCPAN -e'CPAN::Shell->install("HTML::Tagset")'
perl -MCPAN -e'CPAN::Shell->install("HTML::Parser")'
perl -MCPAN -e'CPAN::Shell->install("MIME:Base64")'
perl -MCPAN -e'CPAN::Shell->install("DB_File")'
perl -MCPAN -e'CPAN::Shell->install("DBI")'
perl -MCPAN -e'CPAN::Shell->install("Parse::Syslog")'
perl -MCPAN -e'CPAN::Shell->install("Mail::SPF::Query")'
perl -MCPAN -e'CPAN::Shell->install("IP::Country::Fast")'
perl -MCPAN -e'CPAN::Shell->install("IO::Socket::SSL")'
perl -MCPAN -e'CPAN::Shell->install("Date::Calc")'
perl -MCPAN -e'CPAN::Shell->install("Date::Parse")'
perl -MCPAN -e'CPAN::Shell->install("File::Tail")'
perl -MCPAN -e'CPAN::Shell->install("Time::HiRes")'

Run the script. (Please note that CPAN will ask you some question about the preferred server and proxy settings, you can just hit enter to take default setting.)

sh /root/install_spamd

Make SpamAssassin start with Linux

create the file /etc/init.d/spamd, put the following content in the file.

#!/bin/sh
#
# Startup script for the SpamAssassin SPAMD engine
#
# START THIS BEFORE YOUR MAIL SERVER!
# chkconfig: 345 79 21
# description: SpamAssassin spamd.
# processname: spamd
# Source function library.
. /etc/rc.d/init.d/functions
# Since this is a Perl app and Unicode is slow
# in Perl 5.8 make sure we're using ASCII.
export LANG=C
# Location of the pid file
PID_FILE="/var/run/spamd.pid"
# Max number of spamd threads to allow
MAX_THREADS=10
# See how we were called.
case "$1" in
   start)
            echo -n "Starting SpamAssassin: "
            /usr/bin/spamd -d -m $MAX_THREADS -r $PID_FILE &
            if [ $? ]; then success; else failure; fi
            echo
            ;;
   stop)
            echo -n "Stopping SpamAssassin: "
            kill -term `cat /var/run/spamd.pid` && success ||              failure
            echo
            ;;
   restart)
            $0 stop
            $0 start
            ;;
   *)
            echo "Usage: $0 {start|stop|restart}"
            exit 1
esac

exit 0

Run the following command to make spamassassin when system startup

chmod 755 /etc/init.d/spamd
chkconfig --add spamd
chkconfig --level 35 spamd on
service spamd start

Configure SpamAssassin

There is a very good configuration tools for SpamAssassin http://www.yrex.com/spam/spamconfig.php , most of the settings can take default. But please select Rewrite Subject and select the Languages that your server willing to received. Then download the configure file (local.cf) and put at /etc/mail/spamassassin/ .

Apply the filtering with SpamAssassin

Here we provide the setting on two commonly used MDA Procmail (http://www.procmail.org/) and Maildrop (http://www.courier-mta.org/maildrop/) .

Apply SpamAssassin with procmail

Edit the /etc/procmailrc and put the following content BEFORE other filter and forwarding rules.

:0fw
| /usr/bin/spamc

Apply SpamAssassin with maildrop

Edit the /etc/maildroprc and put the following content at the first line of the file.

DEFAULT=Maildir/
import LOGNAME
xfilter "/usr/bin/spamc -u \$LOGNAME"

Restart Services

Restart the spamd to complete the settings.

/etc/init.d/spamd restart

Other settings

SpamAssassion will change the subject of a spam mail. User can move those email with the mail client build-in email rules function.

Reference

SpamAssassin Offical Website: www.spamassassin.org

TO-DO

  1. Auto-learn settings
  2. Configure using Amavisd

版权所有 © 2007 云南NOD32技术服务中心