Install SpamAssassin on CentOS 6

SpamAssassin is an e-mail spam filter which uses content-matching rules. For this install, CentOS 6.6 (64-bit) and Sendmail are used.

Enable EPEL repository.
One way is to download and install the EPEL repository.

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum install -y epel-release-6.8.noarch.rpm

Another is to edit the /etc/yum.repos.d/epel.repo file and change enabled=0 to enabled=1 under the [epel] section.

[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

Yet another way to enable EPEL repository.

yum install -y yum-utils
yum-config-manager --enable extras
yum install -y epel-release

Install Sendmail and spamassassin.
Note: If Sendmail is already installed, this will not attempt to reinstall it.

yum install sendmail sendmail-cf spamassassin spamass-milter
yum install perl-Mail-SPF perl-Mail-DKIM perl-Razor-Agent pyzor poppler-utils re2c

Start the services manually and automatically survive a reboot.

chkconfig spamassassin on
chkconfig spamass-milter on
service spamassassin start
service spamass-milter start

Append content to the he /etc/mail/sendmail.mc file and rebuild it.

vim /etc/mail/sendmail.mc

Append the following to the end of the file.

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 #

Save and exit the file. Compile the configuration.

/etc/mail/make all

Restart service
service sendmail restart

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

Test the email filter by sending an email from your email client with the following content.
XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X

The email should return with [SPAM] in the subject.

To check the logs

tail -f /var/log/maillog

Further tweaks
Edit /etc/mail/spamassassin/local.cf to enable auto learn.

# These should be safe assumptions and allow for simple visual sifting
# without risking lost emails.

required_hits 4.0
report_safe 1
rewrite_header Subject *****[SPAM](_SCORE_)*****
use_bayes 1
auto_learn 1
ok_languages en
ok_locales en

To see a current list of tests SpamAssassin performs on mail messages to determine if they’re spam or not, check out The Apache SpamAssassin Project.

Source(s)
http://www.linuxquestions.org/questions/fedora-35/spamassassin-how-to-enable-auto-learn-266254/
https://www.rosehosting.com/blog/how-to-install-spamassassin-on-a-virtual-server-with-centos-6/
https://spamassassin.apache.org/tests_3_3_x.html