NOTE: This is designed for UNIX-like systems.
If you are using either pine, elm, mutt, or any other email client in UNIX that allows you to pipe (|) messages to UNIX commands, then these three Korn Shell scripts might come in handy for taking care of false negatives and false positives without having to edit your .whitelist, .blacklist, and .legitlists files directly.
Make sure to put these files in a directory that is in your PATH, or you won't be able to execute them from within you email program.
This is another simple script I wrote that displays mail headers in a mail file from the command line. I use it when I get a "you have mail" message, but I don't want to load up my mail client to see what it is. I hope you find it useful too.
#!/bin/ksh # add an address to the whitelist # or if there are any arguments # add the argument to the whitelist # by Trevor Lalish-Menagh # http://www.trevreport.org/ if [ $# -gt 0 ] ; then echo $1 >> ~/.whitelist cat ~/.whitelist exit fi ADDR=`grep -e ^From: $1 | head -n 1` case $ADDR in *\<* ) ADDR=${ADDR#*<} ADDR=${ADDR%>*} ;; * ) ADDR=${ADDR#* } ;; esac echo $ADDR >> ~/.whitelist cat ~/.whitelist |
#!/bin/ksh # add an address to the blacklist # or if there are any arguments # add the argument to the blacklist # by Trevor Lalish-Menagh # http://www.trevreport.org/ if [ $# -gt 0 ] ; then echo $1 >> ~/.blacklist cat ~/.blacklist exit fi ADDR=`grep -e ^From: $1 | head -n 1` case $ADDR in *\<* ) ADDR=${ADDR#*<} ADDR=${ADDR%>*} ;; * ) ADDR=${ADDR#* } ;; esac echo $ADDR >> ~/.blacklist cat ~/.blacklist |
#!/bin/ksh # add an address to the legitlists # or if there are any arguments # add the argument to the legitlists # by Trevor Lalish-Menagh # http://www.trevreport.org/ if [ $# -gt 0 ] ; then echo $1 >> ~/.legitlists cat ~/.legitlists exit fi ADDR=`grep -e ^To: $1 | head -n 1` case $ADDR in *\<* ) ADDR=${ADDR#*<} ADDR=${ADDR%>*} ;; * ) ADDR=${ADDR#* } ;; esac echo $ADDR >> ~/.legitlists cat ~/.legitlists |
#!/bin/ksh # cm -- Check Mail # Lists the From and Subject lines of all email in a mailbox # ignoring the internal data. Useful for quickly scanning # email headers without starting your mail client. # Written by Trevor Lalish-Menagh Usage () { echo "cm -- Check Mail" echo "Usage: cm [mail file]" exit } if [ $# -lt 1 ] ; then Usage fi if [ -f $1 ] ; then egrep -n '^From: |^Subject: ' $1 |\ egrep -v 'Mail System Internal Data|FOLDER INTERNAL DATA' |\ awk '{ print; if (!(NR % 2)) print " " }' else Usage fi |