Thank you all for the contributions!
I've set up a solution which works great, and i'm very happy with the
results. My solution allows me to turn it on/off per domain. Here's what
i've done to make it work.
First, there's the .qmail-default file under
/home/vpopmail/domains/thedomain.com, my files now contain this:
| /var/qmail/bin/preline /usr/bin/maildrop mailfilter
This means there is a mailfilter file per domain, and this is important
for it allows me to set up the catch-all / bounce / delete behavior.
This is my typical mailfilter file:
---------------------------------------------------------------------------
SHELL="/bin/bash"
import EXT
import HOST
# can be: delete | bounce-no-mailbox | mailbox-name (for catch all)
HANDLER="bounce-no-mailbox"
###########################################################################
#
# Try not to edit below this point unless you really know what you'r
# doing!
#
###########################################################################
VPOP="| /home/vpopmail/bin/vdelivermail '' $HANDLER"
VHOME=`/home/vpopmail/bin/vuserinfo -d [EMAIL PROTECTED]
VDOMHOME=`dirname "$VHOME"`
logfile "/var/log/mailfilter.log"
# check if the user exists
DUMMY=`test -d $VHOME/Maildir/`
if ( $RETURNCODE == 0 )
{
# check if the Junk folder exists
#
DUMMY=`test -d $VHOME/Maildir/.Junk`
if ( $RETURNCODE == 1 )
{
log "MAINT: Creating a spam directory for user
$VHOME/Maildir"
DUMMY=`/usr/bin/maildirmake -f Junk $VHOME/Maildir/`
log "MAINT: $RETURNCODE"
DUMMY=`echo INBOX.Junk >>
$VHOME/Maildir/courierimapsubscribed`
log "MAINT: Done."
}
# check if the message is spam, else deliver normally
#
if ( /^X-Spam-Status: Yes/ )
{
log "SPAM: Message for [EMAIL PROTECTED] delivered to
$VHOME/Maildir/.Junk"
to "$VHOME/Maildir/.Junk"
}
else
{
log "HAM: Message for [EMAIL PROTECTED] handed over to
vdelivermail"
to "$VPOP";
}
}
else
{
# DUMMY=`test -f $VDOMHOME/.qmail-$EXT`
DUMMY=`/home/vpopmail/domains/check_finger.pl [EMAIL PROTECTED]
localhost`
if ( $RETURNCODE == 1 )
{
log "SPAM: No Such User [EMAIL PROTECTED] ??? (finger returned
non-existant mailbox) -- exiting!"
exit
}
else
{
log "HAM: Finger found user [EMAIL PROTECTED] delivering as-is
(probably an alias)"
to "$VPOP";
}
}
---------------------------------------------------------------------------
Notice the HANDLER variable. The default could be "delete" to drop the
mail that falls through, instead of "bounce-no-mailbox".
And here is my check_finger.pl script which better verifies whether or
not a mailbox exists, because my vpopmail uses mysql so it does not
create .qmail-* files for aliases:
---------------------------------------------------------------------------
#!/usr/bin/perl
$hostname = $ARGV[0];
$address = $ARGV[1];
exit 1
unless $hostname && $address;
exit 0 if
$address =~ /^(?:postmaster|abuse|mailer-daemon|root)$/i;
use Net::Finger;
my $finger = finger("[EMAIL PROTECTED]");
if ($finger)
{
exit 0;
}
elsif ( defined $Net::Finger::error )
{
exit 0;
}
exit 1;
---------------------------------------------------------------------------
This script returns error levels to comply with maildrop.
This is it! this solution is elegant, and flexible.
Hope this helps someone.
Skaag