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

How to Become a Better Developer Every Single day

CS371p Spring 2021: Luca Chaves Rodrigues Noronha dos Santos

H2H vs. H2M Conversational Modeling: Part 2 — An example

[Leetcode] Validate Binary Search Tree

Why programming languages are like cleaning agents

5 Wrong Ways To Save Money

Reset MySQL Root Password on MAC

Detecting a User’s Locale in a Web App

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

Google Solution Challenge 2022 Announced 🤩

Improve operational excellence with Zabbix monitoring on AWS

Kubernetes in AWS with KOPs

Colima — Docker & K8S for local development