mds/net-mail/zarafa/files/junklearn.dspam

36 lines
924 B
Plaintext
Raw Normal View History

#!/bin/bash
#WARNING: Don't trust the piped input, its from the end-user. use filtering!
IFS=$' ';
DSPAM_CMD="/usr/bin/dspamc";
#Catch stdin en fetch signature and recipient.
DSPAM_HEADER="`sed 's/[^a-zA-Z0-9 :_.-]//g' | grep -i -e ^X-DSPAM-Signature: -e ^X-DSPAM-Recipient: | tail -n2` " || exit 1
DSPAM_USER="`echo \"$DSPAM_HEADER\" | grep -i ^X-DSPAM-Recipient: | cut -d ' ' -f 2`";
DSPAM_SIGNATURE="`echo \"$DSPAM_HEADER\" | grep -i ^X-DSPAM-Signature: | cut -d ' ' -f 2`";
#Catch parameters
STATUS="$1";
MAIL_ID="$2";
if [[ "$DSPAM_SIGNATURE" && "$DSPAM_USER" && "$STATUS" && "$MAIL_ID" ]]; then
if [ "$STATUS" == "ham" ]; then
CLASS="innocent";
else
CLASS="spam";
fi
logger "$DSPAM_CMD --source=error --class=\"$CLASS\" --signature=\"$DSPAM_SIGNATURE\" --user \"$DSPAM_USER\""
$DSPAM_CMD --source=error --class="$CLASS" --signature="$DSPAM_SIGNATURE" --user "$DSPAM_USER";
exit $?;
fi
exit 1;