+5 votes
199 views
Installing and configuring SpamAssassin on a server

in Security by (551k points)
reopened | 199 views

1 Answer

+3 votes
Best answer

Installing SpamAssasin

One of the most frequent problems is the indiscriminate use when sending and receiving spam by mail.

To solve this problem in a server we can install the SpamAssassin tool, which is a filter that uses heuristic algorithms to identify spam by consulting its database in real time analyzes the text of the email using basic rules, manages checks on headers and body of the email, assigning a score according to the probability that it is spam or unwanted email.

When it detects possible spam it can delete the mail, redirect it to a selected directory or add a warning label. It is an interesting application if the server is used to provide hosting service.

It can be installed in any Linux distribution, this time we will see how to perform the installation for a server with Centos, but it is not difficult to adapt it to any distro.

image


In most of the distro comes the application in the repository but we can download it from http: //spamassassin......./index.html .

To begin we will access via ssh to our server and in the terminal window
We install perl (Perl minimum 5.8.8) and some dependencies to manage mail
yum install perl
yum install perl-Mail-DKIM.noarch

Then we installed the spamassasin
yum install spamassassin

When you have finished installing, we begin to configure it, create a user and a directory for the filters
useradd -d / home / spamfilter -s / bin / false spamfilter
chmod 766 / home / spamfilter

With the nano or vi editor we open the local.cf file to define the filter rules
nano /etc/mail/spamassassin/local.cf


For example, we can define

# Scoring to be marked spam
required_hits 5.0
# Text that will be placed before the subject of emails that are spam
rewrite_header Subject [***** SPAM *****]
# Encapsulate spam in an attachment to the warning email
report_safe 1
# Enable Bayes system
use_bayes 1
# Self-learning
bayes_auto_learn 1
bayes_path / home / spamfilter /
bayes_file_mode 0666
# Spam Checks
skip_rbl_checks 0
use_razor2 1
use_dcc 1
use_pyzor 1

Then we save the file with the name local.cf and leave the editor. In the terminal we restart the service
service spamassassin restart

Spamassasin can be installed on all Cpanel, plesk, directdmin control panels. Here we can see a version of the configuration we made in text mode from directadmin.


image


We can also see a similar system but for the cpanel control panel


image


Configuring the antispam system

To optimize the antispam program we can use the sa -learn command that will allow to define some parameters to train the software. For example, from the command line we type

sa-learn --spam --mbox ~ / mail / spam
This will check spam from mbox-type accounts and send to the spam directory

sa-learn --ham --mbox / var / spool / mail / user
This means valid emails from mbox accounts sent to the user's account

All these configurations can be used by the administrator, by users with reseller accounts or by individual users, since once installed spamassasin can be managed from the control panel, creating the new filters that Spamassassin will train.

This program can also learn only using its heuristic algorithm and the rules that it adds to its database.

by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Jun 23, 2019 in Windows Server by backtothefuture (551k points) | 192 views
+4 votes
1 answer
asked Jun 23, 2019 in Windows Server by backtothefuture (551k points) | 177 views
+3 votes
1 answer
asked Jun 24, 2019 in Linux / Unix by backtothefuture (551k points) | 180 views
+4 votes
1 answer
+3 votes
1 answer
asked Jun 24, 2019 in Windows Server by backtothefuture (551k points) | 184 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users