How to install and set up a well-known e-mail filtering program, spam-assassin on Ubuntu Server 20.04

Follow these steps to filter mail with spam-assassin

Step 1 : Install spam-assassin with the following command:

Step 2 : Create a user account and group for spam-assassin

Step 3 : Change the default settings for the spam daemon. Open /etc/default/spamassassin and update the following lines:

Step 4 : Optionally, configure spam rules by changing values in /etc/spamassassin/local.cf. All lines in this file are commented out by default. You can read the file to see what each rule does.

Step 5 : Next, we need to change the Postfix settings to pass e-mails through spam-assassin. Open /etc/postfix/master.cf

and find the following line And add the following option to it.

Define the content filter block by adding the following lines to the end of the file:

Step 6 : Finally, restart spam-assassin and Postfix

Step 7 : You can check spam-assassin and mail logs to verify that spam-assassin is working properly: