mds/net-mail/zarafa/files/junklearn.dspam
geos_one dc7ad91ee8 net-mail/zarafa: add spamd handler patch and the send as patch
(Portage version: 2.2.0_alpha37/svn/Linux x86_64, RepoMan options: --force)

git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/mds@2912 6952d904-891a-0410-993b-d76249ca496b
2011-06-08 19:54:54 +00:00

36 lines
924 B
Bash
Executable File

#!/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;