[CentOS] Rejecting spam

Tue Mar 4 22:06:58 UTC 2008
John Hinton <webmaster at ew3d.com>

Tim Alberts wrote:
> John Hinton wrote:
>>
>> There are milters for SpamAssassin. You can set them to reject mail 
>> at a particular score level. So, if for instance you felt comfortable 
>> with rejecting mail at a score of 10, which is pretty reliable, you 
>> can also do that at smtp level.
> BINGO  That's exactly what I'm trying to do with spamass-milter.  
> However it either won't do it, or my configuration is incorrect.  Mail 
> marked as spam is still being delivered as normal?

It's how the milter is started. This is my slightly edited 
spamass-milter init.d
file.

---------start--------------

#!/bin/bash
#
# Init file for Spamassassin sendmail milter.
#
# chkconfig: - 80 20
# description: spamass-milter is a daemon which hooks into sendmail and
routes \
#              email messages to spamassassin
#
# processname: spamass-milter
# config: /etc/sysconfig/spamass-milter
# pidfile: /var/run/spamass-milter

source /etc/rc.d/init.d/functions
source /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x /usr/sbin/spamass-milter ] || exit 1

### Default variables
SOCKET="/var/run/spamass.sock"
EXTRA_FLAGS="-r 10"
SYSCONFIG="/etc/sysconfig/spamass-milter"

### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"

RETVAL=0
prog="spamass-milter"
desc="Spamassassin sendmail milter"

start() {
        echo -n $"Starting $desc ($prog): "
        daemon $prog -p $SOCKET -f $EXTRA_FLAGS
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}

stop() {
        echo -n $"Shutting down $desc ($prog): "
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

restart() {
        stop
        start
}

case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        restart
        ;;
  condrestart)
        [ -e /var/lock/subsys/$prog ] && restart
        RETVAL=$?
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        RETVAL=1
esac

exit $RETVAL

--------- end file ---------

The key line is up there with Socket.... Extra Flags. The
EXTRA_FLAGS="-r 10" line means that any email scoring 10 or above is
rejected. Set this to whatever level you feel comfortable with.
Personally after many years at this stuff... I think 10 is more accurate
than a human. Delivering spam scored between 5 and 10 is not so bad.

 From the docs....

     -r nn   Reject scanned email if it greater than or equal to nn.  If
-1, reject scanned email if SpamAssassin tags it as spam
             (useful if you are also using the -u flag, and users have
changed their required_hits value).

My sendmail.mc entry

INPUT_MAIL_FILTER(`spamassassin', `S=local:/var/run/spamass.sock,
F=,T=C:15m;S:4m;R:4m;E:10m')dnl

Have fun!

John Hinton