Skip to content

Instantly share code, notes, and snippets.

@bmatthewshea
Last active August 25, 2022 18:33
Show Gist options
  • Save bmatthewshea/b255322256b4daebd32f2b207e58b3c5 to your computer and use it in GitHub Desktop.
Save bmatthewshea/b255322256b4daebd32f2b207e58b3c5 to your computer and use it in GitHub Desktop.
Spamassassin - Command Line Test Email
#!/bin/bash
def_filename="test.eml"
tmp1="/tmp/emailresults.txt"
tmp2="/tmp/emailresults.log"
usage="
$(basename "$0") [-h] [mailmessage]
Send email through Spamassassin manually and view output
Flags:
-h Show this help
mailmessage Filename of the email to be tested (default: ./${def_filename})
"
# test user data:
if [ "$1" == "-h" ] || [ "$1" == "" ] ; then
printf "$usage"
exit 0
fi
if ! test -f "$1" ; then
printf "\n \"${1}\" not found. Exiting.\n\n"
exit 0
fi
# execute:
( spamassassin -D < $1 2>&1 > "$tmp1" ) > "$tmp2"
# display results
#show results
less "$tmp1"
#show sa log
less "$tmp2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment