Spamassassin

From Edgar BV Wiki
Revision as of 13:26, 29 February 2008 by Red (talk | contribs)
Jump to navigation Jump to search
install the packages. Also install pyzor and razor

create a user "spamfilter"

/etc/spamassassin/local.cf
---------------
# This is the right place to customize your installation of SpamAssassin.
#
# See 'perldoc Mail::SpamAssassin::Conf' for details of what can be
# tweaked.
#
###########################################################################
#
# Debian standard stuff
#
# rewrite_header Subject *****SPAM*****
# report_safe 1
# trusted_networks 212.17.35.
# lock_method flock

# SpamAssassin config file for version 3.x
# NOTE: NOT COMPATIBLE WITH VERSIONS 2.5 or 2.6
# See http://www.yrex.com/spam/spamconfig25.php for earlier versions
# Generated by http://www.yrex.com/spam/spamconfig.php (version 1.50)

# How many hits before a message is considered spam.
 required_score           7.0

# Change the subject of suspected spam
 rewrite_header subject         **Tripany says: SPAM**

# Encapsulate spam in an attachment (0=no, 1=yes, 2=safe)
 report_safe             1

# Enable the Bayes system
 use_bayes               1
 use_bayes_rules        1
        bayes_path        /var/spool/spamassassin/bayes
        bayes_file_mode   0666

# Enable Bayes auto-learning
 bayes_auto_learn              1

# Enable or disable network checks
 skip_rbl_checks         0
 use_razor2              1
 use_dcc                 1
 use_pyzor               1

# Mail using languages used in these country codes will not be marked
# as being possibly spam in a foreign language.
 ok_languages            all

# Mail using locales used in these country codes will not be marked
# as being possibly spam in a foreign language.
 ok_locales              all
--------------------

in /etc/postfix/master.cf
change

--------------------
smtp      inet  n       -       -       -       -       smtpd
--------------------

to

--------------------
smtp      inet  n       -       -       -       -       smtpd
        -o content_filter=spamassassin
--------------------

At the bottom of master.cf add

--------------------
spamassassin unix -     n       n       -       -       pipe
        user=spamfilter argv=/usr/bin/spamc -f -e /usr/sbin/sendmail -oi -f $(sender) $(recipient)
--------------------

This way we throw the mail through spamc, which then filters it through spamd before delivery to the mailbox, instead of sending it through spamassassin itself, which has no control over the amount of process forks it spawns etc. Spamd spawns a certain amount of processes and sticks to them, so it doesn't bring the machine to it's knees.

Per user preferences can be adjusted in ~/.spamassassin/user_prefs (eg. they can turn it off!)

then set /etc/default/spamassassin
ENABLED = 1

/etc/init.d/spamassassin start 

to start spamd.

check /var/log/mail/spamd.log to see what's going on.

To start razor you have to 

        $ razor-client           [creates symbolic links]
        $ razor-admin --create   [creates the razor home]
        $ razor-admin --register [registers an account]

There's a few options to be found in /etc/default/spamassassin (such as that the logfile is in /var/log/mail/spamd.log

NB. Spamassassin doesn't do any deleting in and of itself - it needs another filter (procmail) to do this. So filters in /etc/procmailrc are still run. If you need a personal filter for a single user, you need a 
~/.procmailrc
file.

To simply delete all the spamassassin tagged spam, fill the file with
----------------
:0 HB
* Tripany says: SPAM
/dev/null
----------------