This page is part of the EmailServer article.
Amavisd is a mail filtering interface that allows an MTA such as Postfix to talk to specialzed external add-ons such as SpamAssassin or ClamAV amongst others. On its own, it doesn't do anything useful, but it will make our anstispam and antivirus tools work well together.
It used to require some work to install Amavisd-New but it now has been included in most distributions, so installing it along with its numerous dependencies is as simple as:
Configuring Amavisd-New is simply a matter of editing its /etc/amavisd.conf
and change the following:
Here we tell Amavisd-New that it will be running under the amavis
user account, that its home directory is /var/amavis
and we tell it our domain name as well.
Replacing example.com
with you real domain name.
If you are scanning mail for more than one domain, list them in @local_domains_maps
.
This tells Amavisd-New to always fork 5 children waiting for our mails. This means that, at any time, we'll be able to process 5 emails simultaneously. If you don't have much RAM, you can lower this figure to 2
, but you'll have to reflect that as well in the /etc/postfix/master.cf
(see below) otherwise Postif will expect 5 processes to be available.
Ensures that we always get X-Spam-Status and X-Spam-Level in our email headers, whatever the spam score, that anything above a spam score (see SpamAssassin) will be flagged as spam.
This is what will be shown in the subject of an email detected as spam.
We will quarantine messages containing viruses so they are not delivered to the user (when our antivirus will be installed).
We also disable virus checking for now because we haven't installed the antivirus yet and Amavisd-New will not let mail through if this option is disabled and there is no Antivirus.
Here we make sure that emails containing attachments with banned extensions get bounced. While we'll probably end up trying to bounce viruses and spam, it's better to use this option to let legitimate senders who are sending us banned attachements that their messages did not get through.
We now have a couple of choices: sending our spam to the user with the modified subject line, or quarantine the message by sending it to a special user account.
The most basic setup is to let the user deal with the spam. The good thing about that is that they can judge if there is a false positive, and can still separate the spam by using filters in their mail clients to automatically move marked spam to a local folder.
It is also preferable to do that in a newly setup system as it makes it easier to detect how good your spam catching is and tweak your system.
In /etc/amavisd.conf
change the following:
This will make Amavisd-New ignore any action for spam scores below this figure, which is normally beyond the highest possible spam score.
If instead of cloggin the users with spam messages we want to move them to a special user account on the server, we need to modify the following in /etc/amavisd.conf
:
Edit your /etc/aliases
and append the following to send all notification emails to the existing administrator user account (see the previous DoveCot? section about creating and configuring this account).
Again, don't forget to rebuild the aliases database with postalias /etc/aliases
.
Now we need to let postfix know about Amavisd-New. Postfix communicates with external programs through TCP/IP ports. This method allows a clear separation of processes and their priviledges as each is running under its own account.
Edit the /etc/postfix/master.cf
file and append the following:
Note: if you reduced the number of amavisd
processes ($max_servers
) to launch, you should reflect that number in the first line above as well.
And edit /etc/postfix/main.cf
and append this definition:
If you want to make sure that some addresses always get through and that some always get banned, you will need to create a white list and a black list.
You need to make Amavisd-New know about those files. Edit /etc/amavisd.conf
and add:
Now simply add each email address you want to unconditionnaly allow (white list)/block (black list) on a single line inside the relevant file.
Follow the simple testing procedures listed on the amavisd website to make sure that postfix and amavisd are properly configured:
http://www.ijs.si/software/amavisd/README.postfix.html#basics_testing
The only error you may be getting is related to hte lack of antivirus, something we'll move onto now.
< Dovecot | EmailServer | ClamAV Antivirus >