How to install SpamAssassin on a virtual server with CentOS 6

Leave reply

spamassassin

SpamAssassin is an Open Source mail filter, written in Perl, used for e-mail spam filtering based on content-matching rules. It can be used on a wide variety of email systems including sendmail.

 

SpamAssassin can easily be installed via RPM on a virtual server with CentOS 6 using the following steps:

Enable EPEL repository:

vi /etc/yum.repos.d/epel.repo
[epel]
 name=Extra Packages for Enterprise Linux 6 - $basearch
 #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
 mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
 failovermethod=priority
 enabled=1
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
[epel-debuginfo]
 name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
 #baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
 mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
 failovermethod=priority
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
 gpgcheck=1
[epel-source]
 name=Extra Packages for Enterprise Linux 6 - $basearch - Source
 #baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
 mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
 failovermethod=priority
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
 gpgcheck=1
yum clean all
yum update

Install Sendmail and Spamassassin packages and its dependencies:

yum install sendmail sendmail-cf spamassassin spamass-milter
yum install perl-Mail-SPF perl-Mail-DKIM perl-Razor-Agent pyzor poppler-utils re2c
chkconfig spamassassin on
chkconfig spamass-milter on
service spamassassin start
service spamass-milter start
cd /etc/mail/
vi sendmail.mc

Add the following lines:

dnl #
 dnl # SPAMASSASSIN dnl
 dnl **
 dnl ** enable spamassassin-milter to scan for spam using spamassassin **
 dnl **
 INPUT_MAIL_FILTER(`spamassassin', `S=unix:/var/run/spamass-milter/spamass-milter.sock, F=, T=C:15m;S:4m;R:4m;E:10m')dnl
 define(`confMILTER_MACROS_CONNECT',`t, b, j, _, {daemon_name}, {if_name}, {if_addr}')dnl
 define(`confMILTER_MACROS_HELO',`s, {tls_version}, {cipher}, {cipher_bits}, {cert_subject}, {cert_issuer}')dnl
 dnl # END LOCAL ADDITIONS
 dnl #
make all

Restart Sendmail service for the changes to take effect:

service sendmail restart

In order to make sure that Spamassassin works, execute the following command:

spamassassin -D < /usr/share/doc/spamassassin-3.3.1/sample-spam.txt 2>&1 |grep -i spf

To test your mail setup and verify that the filter is installed correctly and is detecting incoming spam, send an email to an existing email account on the server with the following line in it:

XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

The email should be marked with [SPAM], and if you check the Sendmail log file using the ‘tail -f /var/log/maillog’ command, you should notice something like:

sendmail[4736]: qAGL3ib3004736: Milter add: header: X-Spam-Status: Yes, score=999.9 required=5.0

Of course you don’t have to do any of this if you use one of our linux vps hosting services, in which case you can simply ask our expert linux admins to install this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Leave a Reply


1 × = 1