Article

Table of Contents
Theme:
Was this article helpful?
Try Vultr Today with

$50 Free on Us!

Want to contribute?

You could earn up to $600 by adding new articles.

How to Configure Spamassassin With Postfix on Ubuntu 16.04

Last Updated: Mon, Jan 29, 2018
Email Linux Guides Ubuntu
Archived content

This article is outdated and may not work correctly for current operating systems or software.

Spamassassin is a free and open-source mail filter written in Perl that is used to identify spam using a wide range of heuristic tests on mail headers and body text. It will save your mailbox from much unwanted spam emails.

Prerequisites

  • Before installing Spamassassin, you need to install and configure a mail transfer agent such as Postfix on your virtual private server. The following instructions are for using Spamassassin with Postfix.

  • Verify the server's outbound port status.

Installation Steps

Install Spamassassin.

apt-get install spamassassin spamc

Add a Spamassassin user.

adduser spamd --disabled-login

Setting Up Spamassassin

Edit the configuration settings at /etc/default/spamassassin.

ENABLED=0

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

CRON=1

Now we will edit /etc/spamassassin/local.cf to set up some anti-spam rules.

rewrite_header Subject ***** SPAM _SCORE_ *****

report_safe             0

required_score          5.0

use_bayes               1

use_bayes_rules         1

bayes_auto_learn        1

skip_rbl_checks         0

use_razor2              0

use_dcc                 0

use_pyzor               0

Configuring Postfix

Edit /etc/postfix/master.cf and add a content filter to your SMTP server.

smtp      inet  n       -       -       -       -       smtpd

    -o content_filter=spamassassin

spamassassin unix -     n       n       -       -       pipe

    user=spamd argv=/usr/bin/spamc -f -e  

    /usr/sbin/sendmail -oi -f ${sender} ${recipient}

For the changes to take effect, restart Postfix.

systemctl restart postfix.service

systemctl enable spamassassin.service

systemctl start spamassassin.service

Want to contribute?

You could earn up to $600 by adding new articles.