Amavisd-new is already installed on Snow Leopard. The version that ships with Snow Leopard is 2.6.4. While OS X provides us with a pre-installed version, it is safer for us to install our own version to prevent problems when updates come out. First of all, you need to get the latest source from http://www.ijs.si/software/amavisd/. There are many versions available but we are going to use the most recent stable version.

While amavisd-new is on the system, not all of the prerequisites for its effective use are installed. To install all the extra programs that amavisd needs, we need to use perl and the CPAN system. To install all the prerequisites we need to enter the following command. If this is the first time you have used CPAN through perl then it is going to ask you if it should auto configure. Just hit return and let it do it’s thing. It will need to connect to the internet while it is setting up.

sudo perl -MCPAN -e shell

When it is finished setting everything up it will give you a prompt. DO NOT ATTEMPT TO UPGRADE CPAN AS IT SUGGESTS. If it fails you’re going to be in trouble, and it’s not necessary to try.

At the prompt, enter the following install commands. You will be prompted to install package dependancies. Just hit enter when your asked.

install Mail::DomainKeys
install Net::Server
install Archive::Zip
install Compress::Zlib
install Compress::Raw::Zlib
install Convert::TNEF
install Convert::UUlib
install MIME::Base64
install Mail::Internet
install Digest::MD5
install IO::Stringy
install Time::HiRes
install Unix::Syslog
install BerkeleyDB
install Net::Ident
install Net::LDAP
install Authen::SASL
install MIME::Parser

If any of these don’t install for some reason, don’t panic, move on to the next. Try the failed ones again after the others are installed.

To exit the CPAN shell, just type quit

Now we have the base setup, lets move on to amavisd-new itself.

We are going to put the amavisd program and support programs into /usr/local/bin/ so that it doesn’t conflict with the pre-installed version.

We expand the archive and copy over the files with the following commands.

tar -xvf amavisd-new-2.6.4.tar.gz
cd amavisd-new-2.6.4
sudo mkdir -p /usr/local/bin
sudo cp amavisd /usr/local/bin/
sudo cp amavisd-nanny /usr/local/bin/
sudo cp amavisd-agent /usr/local/bin/
sudo cp amavisd-release /usr/local/bin/
sudo cp amavisd-snmp-subagent /usr/local/bin/

There is a configuration file located at /etc/amavisd.conf. It is the apple supplied config, and we are going to use it as a base for our configuration. Why are we using the apple supplied config for a base? Apple has a great OS that has some specific tweaks, and using their config file for a base is a great way to make sure those tweaks are accounted for. There are a few places in the configuration file that must be altered for it to be properly configured.

Lets start by creating a place for our new directory for our base config and copying the current config file to that directory.

sudo mkdir /etc/amavis
sudo cp /etc/amavisd.conf /etc/amavis/

Because this file from the /etc directory you don’t have permissions to edit it. Before you can make the necessary changes we should get permissions. To do that we enter the following lines:

sudo chmod 0777 /etc/amavis/amavisd.conf

This will give us permissions to edit the file. Once we are finished editing the config file we have to change the permissions back to their original values of -rw-r--r-- (0644). Now we are going to edit the config file for our setup. Open the file /etc/amavis/amavisd.conf in your favorite editor.

At line 20, you need to enter your domain name to replace the example.com that is currently set.

$mydomain = ‘example.com’; # a convenient default for other settings

You should also uncomment line 153 and fill in your domain name

# $myhostname = ‘host.example.com’; # must be a fully-qualified domain name!

The last thing to change is on line 364. We have to tell amavisd where we put the socket file. To do this we change the following line:

\&ask_daemon, ["CONTSCAN {}\n", "/var/amavis/clamd"],

to:

\&ask_daemon, ["CONTSCAN {}\n", "/tmp/clamd.socket"],

That’s all there is to configuring amavisd.

Because we altered the permissions to allow us to edit the file, we should now reset the permissions to their original values. To do that we simply enter:

sudo chmod 0644 /etc/amavis/amavisd.conf