How to Setup SpamAssassin With Postfix On Ubuntu 16.04

Prerequisites

  1. An Alibaba Cloud account.
  2. An Alibaba Cloud ECS instance running Ubuntu 16.04 Linux distribution.
  3. Postfix Email Server. See our guide for setting up an email server with Postfix, Dovecot and SquirrelMail on Ubuntu 16.04 Alibaba ECS
  4. A non-root user that can perform sudo tasks on your server.

Step 1: Installing and Configuring SpamAssassin

$ sudo apt-get update
$ sudo apt-get install spamassassin spamc

Step 2: Creating a User for SpamAssassin

$ sudo adduser spamd --disabled-login

Step 3: Configuring SpamAssassin

$ sudo nano /etc/default/spamassassin
ENABLED =1
SAHOME="/var/log/spamassassin/"
OPTIONS="--create-prefs --max-children 5 --helper-home-dir"
OPTIONS="--create-prefs --max-children 5 --username spamd --helper-home-dir /home/spamd/ -s /home/spamd/spamd.log"
CRON =1

Step 4: Adding Rules to SpamAssassin

$ sudo nano /etc/spamassassin/local.cf
rewrite_header Subject [***** SPAM _SCORE_ *****]
required_score 5.0
use_bayes 1
bayes_auto_learn 1

Step 5: Configuring Postfix to Use SpamAssassin as an Email Filter

$ sudo nano /etc/postfix/master.cf
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}
$ sudo service postfix restart
$ sudo service spamassassin restart

Step 6: Testing SpamAssassin Email Filter

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

Conclusion

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

VIPER of many faces — Part 1

Alibaba Cloud Ranked as Strong Performer in Forrester Wave DaaS Q2 2019

The Pragmatic Programmer EP.6 — Upgrading Your Application

SOLID Design Principles — The Simplest Explanation.

Twilio API — WhatsApp

Banner

Getting Started with Istio Service Mesh

Paxos consensus for beginners (2)

Diving into a new Framework. From Ruby on Rails to ASP .Net — C#

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

How to Implement MySQL Proxy with Rust in Pisa-Proxy?

Generation and installation of SSL certificates for dependencies

Darkflow-Flask: Object Detection Web App on NVIDIA GPU enabled K8s

Kubernetes — How to create a system:masters user and why you REALLY shouldn’t