SpamAssassin

Credits

Various bits of code, scripts, and procedures were put together with information from John Simpson's qmail.jms1.net website. It's an excellent resource on managing and setting up a Qmail server.

Prerequisites
Spamassassin has a boatload of Perl modules that it uses. Some can be installed via yum:

yum -y install perl-HTML-Parser perl-Digest-SHA1 perl-Digest-HMAC perl-Net-DNS
yum -y install perl-HTML-Tagset perl-Time-HiRes perl-DBI

Others are best installed from CPAN:

perl -MCPAN -e shell
install HTML::Parser
install Pod::Usage
install Parse::Syslog
install Statistics::Distributions
install MIME::Base64
install Net::DNS
install Net::SMTP
install Mail::SPF::Query
install LWP
install LWP::UserAgent
install HTTP::Date
install Archive::Tar
install IO::Zlib
install IP::Country::Fast
install Mail::SPF
install Mail::DKIM

Create a user and group for spamassassin to run under:

groupadd spamd
useradd -g spamd -s /home/spamd spamd

Download the latest version (3.2.5 at time of writing):

cd /extra/src
wget http://gulus.USherbrooke.ca/pub/appl/apache/spamassassin/source/Mail-SpamAssassin-3.2.5.tar.gz
tar zxvf Mail-SpamAssassin-3.2.5.tar.gz
cd Mail-SpamAssassin-3.2.5

Compile and install the binaries:

perl Makefile.PL
make
make install

Configure spam filtering options
Edit /etc/mail/spamassassin/local.cf and enable the options you want. Some suggestions are:

# Let the users see what messages were tagged as spam
rewrite_header Subject *****SPAM*****
# Tweak the spam score per your needs
required_score 5.0
# Our SMTP service is doing the RBL checks
skip_rbl_checks 1
#Add X-Spam- headers to message
report_safe 0
# Add a header showing the test scores
add_header all Report _REPORT_

Daemontools startup
Again, rather than using init.d scripts, we'll manage Spamassassin with daemontools. Create the directory for the service:

cd /var/service
mkdir -m 1755 spamd
cd spamd

Then create the run script /var/service/spamd/run:

#!/bin/sh
exec /usr/bin/spamd -L -x -u spamd -s stderr 2>&1

Make it executable:

chmod 755 /var/service/spamd/run

For the logging, we'll use John Simpson's log script:

mkdir -m 755 log
cd log
wget http://qmail.jms1.net/scripts/run.log
mv run.log run
chmod 755 run

Create the symbolic link in /service to start spamd:

ln -s /var/service/spamd /service/

After about 10 seconds, confirm that it is running:

svstat /service/spamd

Recent Updates

  • 6 months 3 weeks ago
    1.27.2 update
  • 7 months 5 days ago
    Drupal 10/11 config
  • 7 months 6 days ago
  • PHP
    7 months 6 days ago
    PHP 8.3.11 and AlmaLinux
  • 7 months 6 days ago
    New version of Pound