Admin/pmail
author wenzelm
Tue Jul 09 11:55:46 2002 +0200 (2002-07-09)
changeset 13321 70a5d5fc081a
parent 13320 2c6ee189ae63
child 14034 55ba81e3502b
permissions -rwxr-xr-x
tuned;
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 # Author: Gerwin Klein, TU Muenchen
     5 # License: GPL (GNU GENERAL PUBLIC LICENSE)
     6 #
     7 # DESCRIPTION: send email platform independently.
     8 
     9 PRG="$(basename "$0")"
    10 
    11 function usage()
    12 {
    13   echo
    14   echo "Usage: $PRG subject recipient body"
    15   echo
    16   echo "  Send email platform independently. Body is a file."
    17   echo
    18   exit 1
    19 }
    20 
    21 function fail()
    22 {
    23   echo "$1" >&2
    24   exit 2
    25 }
    26 
    27 ## main
    28 
    29 # argument checking
    30 
    31 [ "$1" = "-?" ] && usage
    32 [ "$#" != "3" ] && usage
    33 
    34 SUBJECT="$1"
    35 TO="$2"
    36 BODY="$3"
    37 
    38 [ -r "$BODY" ] || fail "could not read $BODY"
    39 
    40 case `uname` in
    41     linux*|Linux*)
    42     mail -s "$SUBJECT" "$TO" < "$BODY"
    43     ;;
    44 
    45     SunOS*)
    46     mail -t "$TO" <<EOF
    47 Subject: $SUBJECT
    48 
    49 `cat $BODY`
    50 EOF
    51     ;;
    52 
    53     *)  
    54     fail "unkown platform"
    55     ;;
    56 esac