2 # Copyright (C) 2008-2013, Eric Wong <e@80x24.org>
3 # License: GPLv3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>
4 # to use with postfix main.cf: mailbox_command = /etc/dc-dlvr "$EXTENSION"
5 DELIVER=/usr/lib/dovecot/deliver
7 # my personal preference is to use a catchall account to avoid generating
8 # backscatter, as invalid emails are usually spam
10 catchall) exec $DELIVER ;;
13 # change if your spamc/spamd listens elsewhere
14 spamc='spamc -U /run/spamd.sock'
16 # allow plus addressing to train spam filters, $1 is the $EXTENSION
17 # which may be "trainspam" or "trainham". Only allow spam training
18 # when $CLIENT_ADDRESS is empty (local client)
19 case $1,$CLIENT_ADDRESS in
20 trainspam,) exec $spamc -L spam > /dev/null 2>&1 ;;
21 trainham,) exec $spamc -L ham > /dev/null 2>&1 ;;
24 TMPMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
27 # pre-filter, for infrequently read lists which do their own spam filtering:
28 if test -r ~/.dc-dlvr.pre
32 DEFAULT_INBOX=$(. ~/.dc-dlvr.pre)
33 if test xINBOX != x"$DEFAULT_INBOX"
35 $DELIVER -m $DEFAULT_INBOX < $TMPMSG
38 PREMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
39 rm_list="$rm_list $PREMSG"
42 $spamc -E --headers < $PREMSG > $TMPMSG
44 $spamc -E --headers > $TMPMSG
52 1) $DELIVER -m INBOX.spam < $TMPMSG ;;
54 # users may override normal delivery and have it go elsewhere
55 if test -r ~/.dc-dlvr.rc
59 $DELIVER -m INBOX < $TMPMSG