Unix/Linux Guru and FOSS supporter

How to Install SpamAssassin on Ubuntu/Debian

What is SpamAssassin?

SpamAssassin is free and Open-source and relies on Perl language to scan and identify email headers, subject lines, and body to keep a server from spam. It will save your mailbox from many unwanted spam emails. In this guide, we will see how to install SpamAssassin on Ubuntu 20.04 server.


Before installing SpamAssassin on our system, we need to install and set up a Mail Transfer Agent (MTA) like Postfix on our server. You can find the installation guide here.

Install Spam-Assassin

Let’s start the SpamAssassin installation process by running the following apt-get command on the shell screen/terminal.

apt-get install spamassassin spamc -y

Configure SpamAssassin

Now we need to configure SpamAssassin to make it workable with the mail client. There are two configuration files that we need to configure. Note that, default configuration file locate at /etc/default/spamassain and another one locate at /etc/spamassassin/ let’s configure the default one first by running the following command and make changes.

nano /etc/default/spamassassin

Set Parameters to:

OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir /home/spamd/ -s /home/spamd/spamd.log"

Open the configuration file using any text editor. Here we will use the nano text editor.

nano /etc/spamassassin/

now remove the comment from the following options and save the configuration file by CTRL+X, Y and enter

rewrite_header Subject *****SPAM*****
report_safe 0
required_score 5.0
use_bayes 1
bayes_auto_learn 1

now test the configuration file

spamassassin --lint


In this tutorial, I had guided you through all the steps to install SpamAssassin in your ubuntu system. You can also follow my other articles.


  1. Thank you, for your tutorial.
    From /etc/default/spamassassin on debian 11:
    #Prior to version 3.4.2-1, spamd could be enabled by setting
    # ENABLED=1 in this file. This is no longer supported. Instead, please
    # use the update-rc.d command, invoked for example as “update-rc.d
    # spamassassin enable”, to enable the spamd service.
    So, I think you should change your tutorial a little bit.


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook