1,094
Friday, 28 February 2020 04:17 (9 bulan yang lalu)    Tulis Komentar

Handle Spam With Spamassassin on Centos 8 & Postfix

Handle Spam With Spamassassin on Centos 8 & Postfix

Spam is very disturbing if mail server is not equiped with anti spam, especially if you have your own mail server, you need to protect your mail from spam. If you use email from famouse email service like gmail, hotmail, aol, protonmail, etc. It's has anti spam built in and you should not worry about that.

If you maintain your own server like you want to your company using email with company domain name or you have application that notifying user with email we need to setup our email server certainly with antispam like spamassassin.

In this article i will show you how to install spamassassin and configure it on Linux Centos 8 & postfix.

Here is my OS and application information on my mail server :

  • Operating System: CentOS Linux 8 (Core)
  • Kernel: Linux 4.18.0-147.5.1.el8_1.x86_64
  • Architecture: x86-64
  • Postfix 3.31

You can check your server info with this command bellow.

Operating System :

hostnamectl

Postfix :

postconf -d | grep mail_version

Spamassassin (if already installed) :

spamassassin -V

Install and Configure Spamassassin

sudo dnf update

sudo dnf install spamassassin

Install Spamassassin

Let's configure spamassassin, create or edit this file

sudo nano /etc/mail/spamassassin/local.cf

Uncomment or insert the following:

required_hits 5.0
report_safe 0
required_score 5
rewrite_header Subject [SPAM]

Spamassassin config file

Create new group and user to run spamassassin

sudo groupadd spamd

sudo useradd -g spamd -s /bin/false -d /var/log/spamassassin spamd

Change owner of spamassassin log file to user spamd

sudo chown spamd:spamd /var/log/spamassassin

Enable spamassassin service to run automaticly when server reboot

sudo systemctl enable spamassassin

Lets start spamassassin service

sudo systemctl start spamassassin

Then update spamassassin database with

sudo sa-update

Configure Postfix to Work with Spamassassin

Open postfix master config

sudo nano /etc/postfix/master.cf

Add filter spamassassin on smtp/smtpd on the top of config file

smtp      inet  n       -       n       -       -       smtpd -o content_filter=spamassassin

And add this line at the end of line of config file

spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Restart postfix service

sudo service postfix restart

Test Spam Detection

We will test by sending email to this mail server with this content message of body :

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

If spamassassin work well this email will receive in yor inbox with [spam] marked on the subject email

spam email

Also you can check your log file

journalctl | grep spam

Automate Update Spamassassin Database

We can running spamassassin update database sa-update automaticly with crond service. We will set it to run automatic every night at 01.00 

Open and edit file 

sudo nano /etc/crontab

Add this cronjob

00 01 * * * root /bin/sa-update && /sbin/service spamassassin restart

Add Cron Job

Restart crond service with

sudo service crond restart

 

spam handle spam spamassassin install spamassassin free email service email service configure smapassassin configure mail server postfix

Komentar

Komentar telah di non-aktifkan untuk postingan ini

Berita Terkait

Latest Article