Sunteți pe pagina 1din 3

SpamAssassin:

Configuring the MTA is far not enough to prevent spam. One of the most powerful
anti-spam tools is probably SpamAssassin.
SpamAssassin (SA) is a perl-program which checks email. According to these
various checks, SA will rate the mail with Spampoints.
Many Spampoints = bad (e.g. most likely spam)
Few Spampoints (or better: negative Spampoints) = good (e.g. most likely ham).
Per default a message is flagged as Spam as soon as it has more than 5 SA-Spam-
Points.

step1: Install SpamAssassin:


$ apt-get install spamassassin

you can install from download latest package


http://apache.claz.org//spamassassin/source/Mail-SpamAssassin-
3.2.5.tar.gz

also by using cpan


$sudo cpan Mail::SpamAssassin

Install ProcMail:
$ apt-get install procmail
-> procmail will deliver the mail to the correct mail- or
spamfolder by reading the Spam/Ham-Flag in the mail-header.

step2:
create user debian-spamd with home directory /var/lib/spamassassin

Step3:
- edit /etc/default/spamassassin
-> ENABLED=1 # starts spamd at boot-time
#add line
SAHOME="/var/lib/spamassassin/"
OPTIONS="--create-prefs --max-children 5 --username debian-spamd
--helper-home-dir ${SAHOME} -s ${SAHOME}spamd.log "

#set
cron=1 #for update

Step4:
- edit /etc/exim4/exim4.conf.template
# add this line at the top of the file:
local_scan_path = /usr/lib/exim4/local_scan/sa-exim.so

- edit /etc/exim4/sa-exim.conf
# change values to fit your needs
# example: reject all mails with a spam-score > 14
SApermreject: 14.0

# If you want to greylist (tempreject) a mail you can configure sa-


exim as follows:
# note: this is why I prefer SA-Exim to directly executing SA in
Exim

#####################################################################
##############
# description: greylist a mail which has a spam-score of 9.0 or
higher (between 9.0 and 14.0 if you have the permreject of above)
# the mail will be temp-rejected for 1800 seconds (most spammers
only send the mail once)
- edit /etc/exim4/sa-exim.conf
SAtempreject: 9.0
SAgreylistiswhitestr: GREYLIST_ISWHITE
SAgreylistraisetempreject: 4.0

- edit /etc/spamassassin/local.cf
# add the following 4 lines:
loadplugin Greylisting
/usr/share/perl5/Mail/SpamAssassin/Plugin/Greylisting.pm
header GREYLIST_ISWHITE eval:greylisting("( 'dir' =>
'/var/spool/sa-exim/tuplets'; 'method' => 'dir'; 'greylistsecs' =>
'1800'; 'dontgreylistthreshold' => 11; 'connectiphdr' => 'X-SA-Exim-
Connect-IP'; 'envfromhdr' => 'X-SA-Exim-Mail-From'; 'rcpttohdr' =>
'X-SA-Exim-Rcpt-To'; 'greylistnullfrom' => 1; 'greylistfourthbyte' =>
0 )")
describe GREYLIST_ISWHITE The incoming server has been freed of
graylisting for this recipient and sender
score GREYLIST_ISWHITE -1

#####################################################################
##############

- create file /etc/procmailrc


MAILDIR=/var/mail
LOGFILE=/var/log/procmail/procmail.log
:0
* ^X-Spam-Status: Yes
$HOME/mail/Spam

--> this is the procmail-configuration, and will do the following:


1) If the Header contains the String '^X-Spam-Status: Yes',
procmail will moved it to the Spam folder

- create directory for global bayes-database:


mkdir -p /var/spamassassin
chown -Rvf debian-spamd:debian-spamd /var/spamassassin

- edit /etc/spamassassin/local.cf (see perldoc for further


info)

bayes_path /var/spamassassin/bayes
report_safe 0
rewrite_subject 0

-> restart spamassassin: /etc/init.d/spamassassin restart


then do testing

--> also check log file


tail -f /var/lib/spamassassin/spamd.log

S-ar putea să vă placă și