Thursday, July 19, 2012

MailScanner with Spamassisn and clamv antivirus


Steps:-

I assume that the Sendmail package is installed by default.

Install MailScanner with SpamAssassin and ClamAV

1. Install SpamAssassin

# yum install spamassassin

No further action is necessary to integrate into MailScanner.

2. Install ClamAV

# yum install clamav clamav-update
Edit and enable freshclam - the clamav update module
# vi /etc/freshclam.conf
.......
# Comment or remove the line below.
#Example
......
Update the ClamAV virus signature. (will be done automatically by MailScanner routinely when integrated.)

# freshclam
Scan file or directory for virus, test clamav is working. "$ man clamscan" for more options.
# clamscan -v -r ~someuser

3. Install MailScanner

Download the latest version of MailScanner tarball from http://www.mailscanner.info/.
At the time of writing, it is MailScanner-4.70.7-1.rpm.tar.gz

# cd /directory/that/you/saved/download
# tar xzf MailScanner-4.70.7-1.rpm.tar.gz
# cd MailScanner-4.70.7-1
# ./install.sh

It would take some time as it installs all Perl prerequisite modules. When done it should install ailScanner service and turn-off sendmail service. (Sendmail will be started/stopped by MailScanner).


To ensure that sendmail service is off, and MailScanner is on,
# /sbin/chkconfig --list sendmail
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off

# /sbin/chkconfig --list MailScanner
MailScanner 0:off 1:off 2:on 3:on 4:on 5:on 6:off

# /sbin/chkconfig sendmail off
# /sbin/chkconfig MailScanner on

Edit /etc/MailScanner/MailScanner.conf file, MailScanner.conf file is fully commented, easy to understand.
Start with simple things such as setting sites and company names. When you are more comfortable with it, work on the rules files.


Start MailScanner (first time) with
# /sbin/service sendmail stop
# /sbin/service MailScanner start
To restart after editing MailScanner.conf
# /sbin/service MailScanner restart

4. Integrate clamav with MailScanner

Next step is optional. Can leave as "auto".
# vi /etc/MailScanner/MailScanner.conf
.....
# This *cannot* be the filename of a ruleset.
#Virus Scanners = auto
Virus Scanners = clamav
.....
Set the correct path for ClamAV scanner
# vi /etc/MailScanner/virus.scanners.conf
....
#clamav /usr/lib/MailScanner/clamav-wrapper /usr/local
clamav /usr/lib/MailScanner/clamav-wrapper /usr
Set the correct path for freshclam

# vi /usr/lib/MailScanner/clamav-autoupdate
# $PackageDir = shift || "/usr/local";
$PackageDir = shift || "/usr";

Restart MailScanner
# /sbin/service MailScanner restart

Check /var/log/maillog for MailScanner messages, look for any errors.
# tail -40f /var/log/messages