maddy/dist/scripts/rspamd-hook
fox.cpp 67092ce58d
dist: Pass {auth_user} to rspamc
Makes integration/rspamd usable for outbound delivery checking.
2019-12-02 19:35:50 +03:00

51 lines
993 B
Bash
Executable file

#!/bin/sh
if [ "$4" != "" ]; then
out=$(rspamc -i "$1" --helo "$2" -F "$3" -u "$4")
else
out=$(rspamc -i "$1" --helo "$2" -F "$3")
fi
action=$(echo "$out" | grep '^Action:' | cut -d " " -f 2-)
score=$(echo "$out" | grep '^Score:' | cut -d " " -f 2)
spam=$(echo "$out" | grep '^Spam:' | cut -d " " -f 2)
echo 'X-Spam-Score:' "$score"
case "$spam" in
"false")
echo 'X-Spam-Flag: NO'
;;
"true")
echo 'X-Spam-Flag: YES'
;;
esac
case "$action" in
"reject")
exit 1
;;
"rewrite subject")
exit 2
;;
"add header")
exit 2
;;
"quarantine")
exit 2
;;
"soft reject")
exit 3
;;
"no action")
exit 0
;;
"greylist")
# Default rspamd configuration uses 'greylist' action a lot, we ignore
# it explicitly since we have no support for greylisting (yet).
exit 0
;;
*)
exit 128
;;
esac