home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2114 / expn
Encoding:
Text File  |  1990-12-28  |  634 b   |  25 lines

  1. #!/bin/sh
  2. #
  3. # This hack runs sendmail in SMTP mode and uses the EXPN command to
  4. # expand an address into the real address(es) that the mail will be
  5. # delivered to.  It takes advantage of sendmail's ability to read
  6. # SMTP commands from standard input when you use the -bs flag.
  7. #
  8. #    Usage:
  9. #        expn alias
  10. #
  11. #    Output:
  12. #        the address(es) mail sent to ``alias'' will really go to
  13.  
  14. if [ -z "$1" ]; then
  15.     echo usage: `basename $0` sendmail-alias
  16.     exit 1
  17. fi
  18. echo "expn $1
  19. quit" | /usr/lib/sendmail -bs | tr -d '\015' | \
  20.     sed -e 's/^250.*<\([^>]*\)>.*/\1/' \
  21.         -e 's/^5[0-9][0-9].\(.*\)/\1/' \
  22.         -e '/^[0-9][0-9][0-9] /d' | sort
  23. exit 0
  24.  
  25.