So, you’re the proud owner of a Plesk-hosted email server. Everything is nice and peachy until you receive the first SPAM (and that will not take long, we’re certain about that). What do you do? Start securing it, of course. In addition to ready-made solutions such as the Plesk Email Security, there is also the possibility of manual setup. Let us show you how.

We’ll look at one of the most frequent cases of mail hosted on Ubuntu, with PostFix activated (default constellation). The here-proposed combination in this article relies on an anti-spam solution (SpamAssassin) – antivirus (ClamAV), synced via Amavis which also acts as a content filter.

Let’s get to work.

First of all, let’s begin with installing all three, with useful appendices:

**sudo apt-get install amavisd-new spamassassin clamav-daemon**

optional packages for better spam detection:

**sudo apt-get install libnet-dns-perl libmail-spf-perl pyzor razor**

and these packages to enable better scanning of any attached archive files:

**sudo apt-get install arj bzip2 cabextract cpio file gzip lha nomarch pax rar unrar unzip unzoo zip zoo**

Step One: Configure SpamAssassin

Apache SpamAssassin provides sysadmins with the most used filter to classify email and block unsolicited bulk email (also known as … spam). For this purpose, it uses a scoring framework and plug-ins to integrate a wide set of heuristic and statistical analysis tests on email headers and body text.

Amavis is its own spamassassin-daemon (using the SpamAssassin libraries), so configuring or starting SpamAssassin is not necessary. You can increase the spam detection rate with SpamAssassin by enabling razor and pyzor. This does not make the object of this blog post, so, let’s continue to…

Step Two: Configure ClamAV

ClamAV® is the open-source standard for mail gateway scanning software. It includes a multi-threaded scanner daemon, command-line utilities for on-demand file scanning, as well as automatic signature updates. Its versatility translates into support for multiple file formats, file and archive unpacking, as well as multiple signature languages.

In the majority of cases, the default behavior of ClamAV will cover all antivirus needs – a daemon (clamd) process is launched and signatures are fetched daily. Advanced ClamAV configuration options are available via the configuration files in **/etc/clamav**.

In order for ClamAV to have access to scan files, simply add the clamav user to the amavis group and the other way around, as follows:

**sudo adduser clamav amavis**

**sudo adduser amavis clamav**

In general, virus scanning results in a rather high memory consumption. It’s worth noting that especially when run on small cloud instances, VPS or routers, memory consumption-related concerns may arise. Mind that you should have at least 4GB RAM memory available on the server.

We need an interface between Postfix and our anti-spam and anti-virus tools. For this purpose, we will use amavisd-new. Amavis is a Perl-written interface between mailer (MTA) and content checkers, optimal for Postfix.

#amavisd #email #security

Secure A Plesk Hosted Email Account Using SpamAssassin, ClamAV And Amavis
2.10 GEEK