2 # Copyright (C) 2008-2019 all contributors <meta@public-inbox.org>
3 # License: GPL-3.0+ <http://www.gnu.org/licenses/gpl-3.0.txt>
4 # This is installed as /etc/dc-dcvr on my system
5 # to use with postfix main.cf: mailbox_command = /etc/dc-dlvr "$EXTENSION"
6 DELIVER=/usr/lib/dovecot/deliver
9 # change if your spamc/spamd listens elsewhere
12 # allow plus addressing to train spam filters, $1 is the $EXTENSION
13 # which may be "trainspam" or "trainham". Only allow spam training
14 # when $CLIENT_ADDRESS is empty (local client)
15 case $1,$CLIENT_ADDRESS in
16 trainspam,) exec $spamc -L spam > /dev/null 2>&1 ;;
17 trainham,) exec $spamc -L ham > /dev/null 2>&1 ;;
20 TMPMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
21 CDMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
22 rm_list="$TMPMSG $CDMSG"
25 $CLAMDSCAN --quiet - <$CDMSG
28 $DELIVER -m INBOX.spam <$CDMSG
32 # pre-filter, for infrequently read lists which do their own spam filtering:
33 if test -r ~/.dc-dlvr.pre
37 DEFAULT_INBOX=$(. ~/.dc-dlvr.pre)
38 case $DEFAULT_INBOX in
39 '') exec rm -f $rm_list ;;
40 INBOX) ;; # do nothing
42 $DELIVER -m $DEFAULT_INBOX <$TMPMSG
46 PREMSG=$(mktemp -t dc-dlvr.orig.$USER.XXXXXX || exit 1)
47 rm_list="$rm_list $PREMSG"
50 $spamc -E --headers <$PREMSG >$TMPMSG
52 $spamc -E --headers <$CDMSG >$TMPMSG
60 1) $DELIVER -m INBOX.spam <$TMPMSG ;;
62 # users may override normal delivery and have it go elsewhere
63 if test -r ~/.dc-dlvr.rc
67 $DELIVER -m INBOX <$TMPMSG