source: npl/mailserver/netqmail/syn3-dagent @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 1.3 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#check if user exists or fail permanent
18#(id will generate a nice error message)
19id "$USER" >/dev/null || end 100
20
21#store mail temporary
22cat > $INMAIL || end 1
23
24#pipe trough personal spamfilter of this user
25if ! grep "VIRUS.*IN MAIL TO YOU" $INMAIL >/dev/null && /usr/bin/dspamc --user "$USER" --deliver=innocent,spam --mail-from="$SENDER" --stdout >$SCANMAIL <$INMAIL; then
26        #it worked
27        if grep "^X-DSPAM-Result: Spam" $SCANMAIL >/dev/null; then
28                SPAM=1
29        else
30                SPAM=
31        fi
32        MAIL=$SCANMAIL
33else
34        #spam filter is broken, or it was just a virus notification
35        MAIL=$INMAIL
36        SPAM=
37fi
38
39#check cyrus is up, and deliver it there:
40if /usr/bin/pgrep -f -x /usr/cyrus/bin/master ; then
41        if [ "$SPAM" ]; then
42                /usr/cyrus/bin/deliver -a "$USER" -m Spam "$USER" < $MAIL
43                end $?
44        else
45                /usr/cyrus/bin/deliver -a "$USER" "$USER" < $MAIL
46                end $?
47        fi
48fi
49
50#check zarafa is up, and deliver it there:
51if pidof zarafa-server >/dev/null; then
52        if [ "$SPAM" ]; then
53                /usr/bin/zarafa-dagent "$USER" -q -j < $MAIL
54                end $?
55        else
56                /usr/bin/zarafa-dagent "$USER" -q < $MAIL
57                end $?
58        fi
59fi
60
61#no backend mailstorage up, so fail temporary
62echo "All mailbackends are down, retry again later..."
63end 1
Note: See TracBrowser for help on using the repository browser.