$ cat /usr/local/vpopmail/etc/tcp.smtp
127.:allow,RELAYCLIENT=""
:allow,QMAILQUEUE="/var/qmail/bin/qmail-localfilter.sh",GREYLIST="Y"
$ cat /var/qmail/bin/qmail-localfilter.sh
#!/bin/sh
exec /usr/local/bin/qmail-qfilter ${SPAMC_BIN}/spamc ${SPAMC_FLAGS} -- ${QMAIL_LOCALFILTER_BIN}/qmail-localfilter.pl ${QMAIL_LOCALFILTER_FLAGS}
$ file /usr/local/bin/qmail-qfilter
/usr/local/bin/qmail-qfilter: ELF 64-bit LSB executable, x86-64, version 1 (OS), dynamically linked, interpreter /libexec/ld-elf.so.1, for OS x.y stripped
$ file /var/qmail/bin/qmail-localfilter.pl
/var/qmail/bin/qmail-localfilter.pl: a /usr/local/bin/perl script, ASCII text executable
qmail-qfilter, qmail-queue multi-filter front end
Installing qmail-qfilter
# [...]
$log_facility = "mail";
if($opt_s)
{
$log_facility = $opt_s;
}
# [...]
# Begin by processing the mail header...
while(<>) {
# [...]
# Check for an "X-Spam-Flag: YES" line
# If we find one, this piece of crap is busted.
if (/^X-Spam-Flag: YES/oi) {
$spam = 1;
$opt_d and warn "DEBUG: Mail is spam!\n";
}
# [...]
}
#
# If this is spam, log that we have rejected it, (with the
# "from" and "to" lines if possible), include the reason why it
# was rejected, (if we have it), and exit with status code 31.
#
if ($spam) {
setlogsock('unix');
openlog('qmail-localfilter.pl','0',$log_facility);
if ($have_from) {
syslog('info',"Rejected spam $from $to");
} else {
if ($have_to) {
syslog('info',"Rejected spam $to");
} else {
syslog('info',"Rejected spam.");
}
}
if ($have_reason) {
syslog('info',"$reason");
}
exit 31
}
# [...]