(原創)在QMAIL中將整個DOMAIN 的 spam mail 過濾到.Trash下

cd 需過濾 spam mail的domain DIR下

vi .qmail-default
| /var/qmail/bin/preline /usr/local/bin/maildrop /home/vpopmail/bin/filter-spam-to-trash
| /home/vpopmail/qtrap/block-spam.sh
| /home/vpopmail/bin/vdelivermail '' bounce-no-mailbox


vi /home/vpopmail/bin/filter-spam-to-trash
import EXT
import HOST
VHOME=`/home/vpopmail/bin/vuserinfo -d $EXT@$HOST`

if (/^X-Spam-Status: Yes/:h)
{
    to $VHOME/Maildir/.Trash/
}
else
{
    exit
}


vi /home/vpopmail/qtrap/block-spam.sh
#!/bin/sh

checkall () {
 case $BANNED_WORDS in
 Doctor|+++++Trash+++++)
   echo MESSAGE DROPPED from $SENDER because of $BANNED_WORDS on `date "+%D %H:%M:%S"` >> /home/vpopmail/qtrap/logs/qtrap.log
   exit 99;;
  *)
   ;;
  esac
}

CONTENT=`(cat)`
for BANNED_WORDS in $CONTENT
do
 checkall $BANNED_WORDS
done
exit 0