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

Why programming language is difficult to learn?

Bug Disclosure — Solidity Code Generation Bug Can Cause Memory Corruption

Serverless: Functions in the Cloud

5 Skills Needed to Become a Technical PM

EASY GUIDE FOR NEWBIES

Data Structures Part 1: Essentials

22. Sharing Memories of a Shared Memory Architecture

Communicating with APIs through Fetch Requests

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

F5 Advanced Web Application Firewall(AWAF) 101

Learning note for Docker (1) — How to use insecure docker registry?

Self managed EFK Setup for 10 billion+ documents

Introduction to CI pipelines on Github

Two people looking at code on a Silver Macbook Pro https://www.pexels.com/@divinetechygirl?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels