Layout copyright © 2002,2003,2004 Christoph Haas
Copyright © 2005 Jasper Slits
| Revision History | |
|---|---|
| $Rev: 16 $ | $Date$ |
Abstract
This tutorial provides an alternative to amavisd-new based set ups for anti-virus and spam filtering.I wanted to have a light-weight set up and avoid amavis because I do not like it, too much settings etc.
After looking at Freshmeat I noticed clamsmtp which was at version 0.4 at the time I started using it. From the homepage: "ClamSMTP aims to be lightweight, reliable, and simple rather than have a myriad of options. It's written in C without major dependencies."
The current version in the Debian repository is the latest release of clamsmtp: 1.4.1
Table of Contents
![]() | |
|
As of now (June 25th 2005), the current package of 'maildrop' in Debian
Sid is 1.5.3, which is outdated. A recent maildrop can be found in experimental but you need other packages too.
It might break your current set up, if you're using courier-imap and/or courier-pop.
| |
wget http://debian.concepts.nl/debian/pool/main/c/courier/courier-base_0.50.0-0.1_i386.deb wget http://debian.concepts.nl/debian/pool/main/c/courier-authlib/courier-authlib_0.56-0.5_i386.deb wget http://debian.concepts.nl/debian/pool/main/c/courier-authlib/courier-authlib-mysql_0.56-0.5_i386.de wget http://debian.concepts.nl/debian/pool/main/m/maildrop/maildrop_1.8.1-2_i386.debInstall the packages in the same order as you downloaded them. Beware of dependency problems (all solvable).
[root@malochia:~]# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
43D82783B734 9090 Sun Jun 26 08:47:39 sender@domain.org
(temporary failure. Command output: maildrop: maildir over quota.)
info@somedomain.org
Prior to 1.8.0 overquota mails were bounced rather than queued up.
echo "some random data" > /tmp/randomfile su - vmail maildrop -d valid@user.tld -V 10 < /tmp/randomfileIn case of problems: Use courierauthtest or 'strace' and look for 'Permission denied' and alike messages.
# AV scan filter (used by content_filter) clamsmtp
scan unix - - n - 16 smtp
-o smtp_send_xforward_command=yes
# For injecting mail back into postfix from the filter
127.0.0.1:10026 inet n - n - 16 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
maildrop unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/bin/maildrop -d ${recipient}
# Use the scan transport as defined in master.cf as a content-filter content_filter = scan:127.0.0.1:10024 # Deliver all mail to the maildrop transport as defined in master.cf virtual_transport = maildrop local_transport = maildrop maildrop_destination_recipient_limit = 1
OutAddress: 10026 Listen: 127.0.0.1:10024 ClamAddress: /var/run/clamav/clamd.ctl TempDirectory: /var/spool/clamsmtp
The OutAddress must match the setting in master.cf and the Listen address must match the setting in main.cf
Mar 28 19:10:49 servername clamsmtpd: 1000EA: from=sender@domain.tld,to=recipient@domain.tld, status=CLEAN
Mar 25 17:42:32 servername clamsmtpd: 108501: from=support_ref_0236020@regions.com, to=recipient@domain.tld,status=VIRUS:HTML.Phishing.Bank-1 Mar 25 17:42:32 servername postfix/smtp[9602]: 564757853969: to=There are several ways to use Spamassassin, but as a maildrop advocate I prefer the use of maildrop with spamc/spamd and a whitelist. First, the whitelist is implemented in maildrop to avoid invoking spamassassin and is based on the sender. The file /etc/maildrop/from_whitelist.dat contains regular expressions with e-mail addresses:, relay=127.0.0.1[127.0.0.1], delay=32, status=sent (250 Virus Detected; Discarded Email)
.*@(ebay|microsoft|webshots|hallmark|novell|mundo-perdido|localhost|dell).com email@adres.tld
The same can be done for recipient based whitelisting. It's not possible to have per-user whitelists. You can whitelist here all domains you receive mail for. Might be good to make it dynamic though it'll probably kill the effiency
# Do not call SA when the sender is in the whitelist.
if (/^From: *!.*/ && lookup(getaddr($MATCH2),"/etc/maildrop/from_whitelist.dat"))
{
log "Spam: sender found in whitelist"
to $HOME
}
# Avoid scanning of large emails
if ( $SIZE < 50000 )
{
# -f -> do not bail out when spamd is down
# -u amavis unprivileged account
exception {
xfilter "/usr/bin/spamc -f -u amavis"
}
}
# Count amount of * to determine where to deliver mail
if (/^X-Spam-Status: Yes, score=*!.* !.*/)
{
if ( $MATCH2 > 5 )
{
# Log original recipient in /var/vmail/maildrop.log
log "To : $LOGNAME"
to /var/vmail/spambox
}
else
{
# Tagged as spam but not exceed the treshhold value of 5
to $HOME
}
}
else
{
# Not whitelisted and no spam
to $HOME
}
More information about the software discussed can be found here:
Credits where credits are due: