postfix + SpamAssassin with SPAM Quarantine

here's the postfix + SpamAssassin with SPAM Quarantine

same as you did with the basic script here

1. Install SpamAssassin

if you need any help visit
http://spamassassin.apache.org/

add a user call spamfilter with out shell.

CODE:
adduser spamfilter -s /sbin/nologin




2. Setup Postfix

edit the master.cf

add the line

CODE:
spamfilter unix - n n - - pipe
flags=Rq user=spamfilter argv=/usr/local/bin/spamfilter -f ${sender} -- ${recipient}





edit the SMTP as

CODE:
smtp     inet n     -     n     -     -     smtpd
    -o content_filter=spamfilter:dummy





now create a file call

/usr/local/bin/spamfilter

eg

CODE:
vi /usr/local/bin/spamfilter



QUOTE:
# Kalinga Athulathmudali
# 2006-01-06
# Variables

SENDMAIL="/usr/sbin/sendmail.postfix -i"
EGREP=/bin/egrep

# Exit codes from <sysexits.h>

EX_UNAVAILABLE=69

# Number of *'s in X-Spam-level header needed to sideline message:
# (Eg. Score of 5.5 = "*****" )

SPAMLIMIT=5

# Clean up when done or when aborting.

trap "rm -f /var/tempfs/out.$$" 0 1 2 3 15

# Pipe message to spamc

cat | /usr/bin/spamc -u filter > /var/tempfs/out.$$

if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < /var/tempfs/out.$$

  then

## Change the Email address where you want your spam to get fwd to

  $SENDMAIL -f spamadmin@yourdomain.com spamtrap@yourdomain.com < /var/tempfs/out.$$

  else


  $SENDMAIL "$@" < /var/tempfs/out.$$

  fi

# Postfix returns the exit status of the Postfix sendmail command.

exit $?




now chnage the email address in script

your admin email address spamadmin@yourdomain.com
this is where your spam get fwd to spamtrap@yourdomain.com


now chnage the owner of the file to spamfilter


CODE:
chown spamfilter /usr/local/bin/spamfilter



now set permisson as

QUOTE:
chmod 755 /usr/local/bin/spamfilter



creat a dir call tempfs in var

CODE:
mkdir /var/tempfs



chnage the folder owner to spamfilter

CODE:
chown spamfilter:root /var/tempfs



reload postfix

CODE:
/etc/init.d/postfix reload



your done.

原文出处:
http://onetforum.com/fourm/viewtopic.php?t=34

分享到