home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Mail / stopthatmail-1.1 / stopthatmail
Encoding:
Text File  |  1997-03-06  |  1.7 KB  |  77 lines

  1. #!/bin/sh
  2. #
  3. # AUTHOR:  Timothy J. Luoma <luomat@peak.org>
  4. #
  5. # VERSION: 1.1.0
  6. #
  7. # DATE: 6 March 1997   
  8. #
  9. # WARNING: USE ENTIRELY AT YOUR OWN RISK
  10. #
  11. # PURPOSE: To use as a Mail.app mailer as a safety-net against
  12. #    accidentally 'sending' a message
  13. #
  14. # TESTED UNDER: NeXTStep 3.2 and 3.3 on my NeXTStation
  15. #
  16. # USAGE NOTES: chmod 755 stopthatmail && mv stopthatmail /usr/local/bin
  17. # Set your Mail.app mailer (Expert preferences) to 
  18. # /usr/local/bin/stopthatmail or wherever you put it.
  19. #
  20. # NOTE: This may not work with any other version of Mail.app than 3.3
  21. #
  22. # REQUIRES: the "Alert" binary from the "Shell Panels" package 
  23. # (ShellPanel.2.0.NIHS.bs.tar.gz) which can be found at
  24. # ftp://ftp.next.peak.org/pub/next/apps/utils/unix/
  25. #
  26. # KNOWN BUGS: 
  27. #    1) the "Return to me" does not work with the Mail.app in 3.2
  28. #    2) addresses must have an "@" in them
  29. #
  30. #
  31. # HISTORY:
  32. #    1.1 - fixed munging of multiple addresses in version 1.0
  33. #    1.0 - released for 45 minutes (see bugfix listed for 1.1)
  34. #
  35.  
  36. name=`basename $0`
  37.  
  38. SUBJECT=`cat - | grep "^Subject:" `
  39.  
  40. # this is to strip everything except the actual address
  41. #
  42. ADDRESSES=`echo $*| tr -s ' ' '\012' | grep "@" | tr -s '\012' ' ' `
  43.  
  44. Alert -t "$SUBJECT" \
  45.     "Deliver message to $ADDRESSES ?" \
  46.     "Yes" "No" "Return to me"
  47.  
  48. exitcode="$?"
  49.  
  50.  
  51. case $exitcode in
  52.     0) /usr/lib/sendmail -oi -odb $ADDRESSES &&
  53.         echo "$name: sent /usr/lib/sendmail -oi -odb $ADDRESSES" \
  54.             >/dev/console && exit 0
  55.         
  56.         echo "$name[$$]: something went wrong, message not sent" \
  57.             >/dev/console
  58.     ;;
  59.  
  60.  
  61.     1) echo "$name[$$]: cancelling message to $ADDRESSES" \
  62.         >/dev/console
  63.        exit 0
  64.         
  65.     ;;
  66.     
  67.     *) echo "$name[$$]: Returning message to `whoami`">/dev/console
  68.        kill -9 $$
  69.         
  70.     ;;
  71. esac
  72.  
  73. #echo "$name[$$]: exited with code $exitcode" >/dev/console
  74.  
  75. exit 0
  76. #end
  77.