Spamassassin and Postifx configuration

http://www.akadia.com/services/postfix_spamassassin.html

aptitude install spamassassin spamc

/etc/default/spamassassin

ENABLED=1
SAHOME="/var/log/spamassassin/"
OPTIONS="--create-prefs --max-children 2 --username debian-spamd -H ${SAHOME} -s ${SAHOME}spamd.log"
PIDFILE="/var/run/spamd.pid"
CRON=1

/etc/postfix/master.cf

smtp inet n - - - - smtpd -o content_filter=spamfilter
spamfilter unix - n n - - pipe
flags=Rq user=debian-spamd argv=/usr/local/bin/spamfilter.sh -oi -f ${sender} ${recipient}

mkdir /var/spamchk
chmod 775 /var/spamchk
chown debian-spamd:debian-spamd /var/spamchk

/usr/local/bin/spamfilter.sh

#!/bin/sh
# -----------------------------------------------------------------
# File: spamchk
#
# Purpose: SPAMASSASIN shell-based filter
#
# Location: /usr/local/bin
#
# Usage: Call this script from master.cf (Postfix)
#
# Certified: Ubuntu Linux, Spamassassin 3.3.x, Postfix 2.7.x
# -----------------------------------------------------------------
# Variables
SENDMAIL="/usr/sbin/sendmail -i"
EGREP=/bin/egrep
TMPFILE=/tmp/spamchk.$$
SIDELINE_DIR=/var/spamchk
# Number of *'s in X-Spam-level header needed to sideline message:
# (Eg. Score of 5.5 = "*****" )
SPAMLIMIT=3
# Clean up when done or when aborting.
trap "rm -f $TMPFILE" 0 1 2 3 15
# Pipe message to spamc and store in $TMPFILE
cat | /usr/bin/spamc -u filter | sed 's/^\.$/../' > $TMPFILE
# Are there more than $SPAMLIMIT stars in X-Spam-Level header?
if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < $TMPFILE
then
# Option 1: Move high scoring messages to sideline dir so
# a human can look at them later:
mv $TMPFILE $SIDELINE_DIR/`date +%Y-%m-%d_%R`-$$
# Option 2: Divert to an alternate e-mail address:
# $SENDMAIL xyz@xxxx.xx < $TMPFILE
# Option 3: Delete the message
# rm -f $TMPFILE
else
$SENDMAIL "$@" < $TMPFILE
fi
# Postfix returns the exit status of the Postfix sendmail command.
exit $?

/etc/spamassassin/local.cf

rewrite_header Subject *****SPAM***** (_SCORE_)
report_safe 0
trusted_networks 192.168.122.
required_score 3.0
use_bayes 1
bayes_auto_learn 1
ifplugin Mail::SpamAssassin::Plugin::Shortcircuit
shortcircuit ALL_TRUSTED on
endif # Mail::SpamAssassin::Plugin::Shortcircuit

service spamassassin start
service postfix restart