Comments on Integrating amavisd-new Into Postfix For Spam- And Virus-Scanning
Integrating amavisd-new Into Postfix For Spam- And Virus-Scanning This article shows how to integrate amavisd-new into a Postfix mail server for spam- and virus-scanning. amavisd-new is a high-performance interface between MTAs such as Postfix and content checkers: virus scanners, and/or SpamAssassin. We will use ClamAV for virus scanning and SpamAssassin for spam scanning in this tutorial.
1 Comment(s)
Comments
We use the following script that runs every night via cron job (clam antivirus needs to be installed), it seems to work very well. It scans both email and websites. Use at your own risk.
#!/bin/bash
LOGFILE="/var/log/clamav/clamav-$(date +'%Y-%m-%d').log";
set HOST="$(hostname -f)"
EMAIL_FROM="[email protected]";
EMAIL_TO="[email protected]";
DIRTOSCAN="/var/www /var/vmail";
for S in ${DIRTOSCAN}; do
DIRSIZE=$(du -sh "$S" 2>/dev/null | cut -f1);
echo "Starting a daily scan of "$S" directory.
Amount of data to be scanned is "$DIRSIZE".";
clamscan -ri "$S" >> "$LOGFILE";
# get the value of "Infected lines"
MALWARE=$(tail "$LOGFILE"|grep Infected|cut -d" " -f3);
# if the value is not equal to zero, send an email with the log file attached
if [ "$MALWARE" -ne "0" ];then
# using heirloom-mailx below
cat "$LOGFILE" | mail -s "Malware Found on $HOST" "$EMAIL_FROM" "$EMAIL_TO";
fi
done
exit 0