source: npl/mailserver/netqmail/syn3-dagent @ 128fde4

gcc484perl-5.22
Last change on this file since 128fde4 was 402b138, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

no longer bounce mails that are send to invalid adresses (too much bounchspammers)

  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/bin/bash
2
3USER="$1"
4SENDER="$2"
5INMAIL=/tmp/syn3-dagent.$$
6SCANMAIL=/tmp/syn3-dagent-scanned.$$
7
8
9#cleanup and exit
10end()
11{
12        rm $INMAIL 2>/dev/null
13        rm $SCANMAIL 2>/dev/null
14        exit $1
15}
16
17# some kind of ldap problem, try again later
18id "Administrator" >/dev/null || end 111
19
20#does the user exists?
21if ! id "$USER" >/dev/null; then
22        #we're sure theres no ldap problem?
23        id "Administrator" >/dev/null || end 111
24        #probably a bounce spammer, drop mail silently
25        echo "User does not exist, dropping mail."
26        end 0
27fi
28
29#store mail temporary
30cat > $INMAIL || end 1
31
32#pipe trough personal spamfilter of this user
33if ! grep "VIRUS.*IN MAIL TO YOU" $INMAIL >/dev/null && /usr/bin/dspamc --user "$USER" --deliver=innocent,spam --mail-from="$SENDER" --stdout >$SCANMAIL <$INMAIL; then
34        #it worked
35        if grep "^X-DSPAM-Result: Spam" $SCANMAIL >/dev/null; then
36                SPAM=1
37        else
38                SPAM=
39        fi
40        MAIL=$SCANMAIL
41else
42        #spam filter is broken, or it was just a virus notification
43        MAIL=$INMAIL
44        SPAM=
45fi
46
47#check cyrus is up, and deliver it there:
48if /usr/bin/pgrep -f -x /usr/cyrus/bin/master ; then
49        if [ "$SPAM" ]; then
50                /usr/cyrus/bin/deliver -a "$USER" -m Spam "$USER" < $MAIL
51                end $?
52        else
53                /usr/cyrus/bin/deliver -a "$USER" "$USER" < $MAIL
54                end $?
55        fi
56fi
57
58#check zarafa is up, and deliver it there:
59if pidof zarafa-server >/dev/null; then
60        if [ "$SPAM" ]; then
61                /usr/bin/zarafa-dagent "$USER" -q -j < $MAIL
62                end $?
63        else
64                /usr/bin/zarafa-dagent "$USER" -q < $MAIL
65                end $?
66        fi
67fi
68
69#no backend mailstorage up, so fail temporary
70echo "All mailbackends are down, retry again later..."
71end 111
Note: See TracBrowser for help on using the repository browser.