4 echo "This program needs two parameters. The first is the directory where spam"
5 echo "emails are stored. The second parameter is a text file containing non-spammy"
6 echo "email addresses (that is, a whitelist of good email addresses--people who are"
7 echo "allowed to send you email). The script will scan that directory for any email"
8 echo "addresses in the whitelist file and report files that might potentially not be"
9 echo "spam (i.e., false positives)."
13 if [ ! -d "$1" ]; then
14 echo "This program needs a spam email *directory* as its first parameter."
18 if [ ! -f "$2" ]; then
19 echo "This program needs a whitelist *file* as its second parameter."
23 export SCAN_DIR="$1" # where we will scan spam emails.
24 export ADDRESS_FILE="$2" # where our addresses live.
26 # a generated script that reports when a matching pattern was found in a file.
27 export ITERATE_COMMAND="$(mktemp "$TMP/zz_saitercmd.XXXXXX")"
28 # was in there "$2" but not defined?
31 if [ ! -z "$(head -50 "$1" | grep "From:" | grep -f "$ADDRESS_FILE" -i )" ]; then \
34 if [ ! -z "$matched" ]; then \
35 echo "found non-spam email address in : $matched"; \
39 find $SCAN_DIR -type f -exec bash $ITERATE_COMMAND "{}" ';'
41 rm -f $ITERATE_COMMAND