Last active
March 17, 2017 05:48
-
-
Save moisseev/3cd6f0eef59bfc84ec6ace7ec584ef67 to your computer and use it in GitHub Desktop.
Check DKIM signatures of messages stored in a Maildir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
MAILDIR="/vmail/example.com/test/Maildir" | |
DIR_BAD="$MAILDIR/.dkim_bad/new" | |
DIR_GOOD="$MAILDIR/.dkim_good/new" | |
DIR_NO_SIG="$MAILDIR/.dkim_no_sig/new" | |
#------------------------------- | |
MODE_SORT= | |
PROGNAME=`basename $0` | |
PROGDESCR="$PROGNAME - check DKIM signatures of messages stored in a Maildir" | |
usage () { | |
cat >&2 <<EOF | |
$PROGDESCR | |
usage: $PROGNAME [-s|-h] | |
-s sort messages using predefined directories | |
-h brief help | |
EOF | |
} | |
while getopts sh opt; do | |
case "$opt" in | |
s) | |
MODE_SORT=1;; | |
# \? - unknown flag | |
h|?) | |
usage | |
[ $opt = "h" ] && exit 0 | |
exit 1;; | |
esac | |
done | |
cd $MAILDIR || exit 1 | |
for MSG in ./cur/* ./new/* ; do | |
[ -f "$MSG" ] || continue | |
RES=`zcat -f "$MSG" | opendkim-testmsg 2>&1` | |
printf '.' | |
[ $? -ne "0" ] && printf "$MSG\n\n" | |
case "$RES" in | |
'') | |
[ $MODE_SORT ] && mv "$MSG" "$DIR_GOOD/";; | |
'opendkim-testmsg: dkim_eom(): Bad signature') | |
printf "\nBad signature: $MSG\n" | |
[ $MODE_SORT ] && mv "$MSG" "$DIR_BAD/";; | |
'opendkim-testmsg: dkim_chunk(): No signature') | |
printf "\nNo signature: $MSG\n" | |
[ $MODE_SORT ] && mv "$MSG" "$DIR_NO_SIG/";; | |
*) | |
echo "Unknown test result: $RES";; | |
esac | |
done | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dovecot passwd-file entry:
main.cf:
sender_bcc: