home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / uk-sendmail2.1 / Support / distribute < prev    next >
Encoding:
Text File  |  1991-06-11  |  1.2 KB  |  52 lines

  1. #!/bin/sh
  2. #
  3. #  Send a mail message to users on a distribution list.  The message header is
  4. #  altered mainly to allow error messages to be returned to the list maintainer.
  5. #  This script should be setuid to one of sendmail's trusted users.
  6. #
  7. #  Usage: put an entry into /usr/lib/aliases in one of the following forms:
  8. #
  9. #    list-name: "|/usr/local/lib/distribute list-name user1 user2 ..."
  10. #    list-name: "|/usr/local/lib/distribute list-name :include:pathname"
  11. #
  12. if [ $# -lt 2 ]
  13. then
  14.     echo Usage: $0 list-name user1 user2 ...
  15.     exit 64
  16. fi
  17.  
  18. dlist=$1
  19. dusers=""
  20. shift
  21.  
  22. #  gather distribution list usernames
  23. for i in $*
  24. do
  25.     case $i in
  26.     :include:*)
  27.         file=`expr $i : ':include:\(.*\)'`
  28.         if [ -f $file ]
  29.         then
  30.             dusers="$dusers `cat $file`"
  31.         else
  32.             echo $i: No such file or directory
  33.             exit 64
  34.         fi
  35.         ;;
  36.     *)    dusers="$dusers $i"
  37.         ;;
  38.     esac
  39. done
  40.  
  41. #  adjust headers of incoming message
  42. sed -e '1,/^$/s/^$/EOH\
  43. /'                    |
  44. sed -e '/^$/,$b'            \
  45.     -e '/^From /d'            \
  46.     -e '/^Via:/s//Original-Via:/'    \
  47.     -e '/^Sender:/s//Original-Sender:/'    \
  48.     -e '/^Acknowledge-To:/d'        \
  49.     -e '/^Return-Receipt-To:/d'        \
  50.     -e "/^EOH$/s//Sender: $dlist-request/" |
  51. /usr/lib/sendmail -f$dlist-request $dusers
  52.