Admin/pmail
author isatest
Tue Jul 09 11:46:36 2002 +0200 (2002-07-09)
changeset 13320 2c6ee189ae63
child 13321 70a5d5fc081a
permissions -rwxr-xr-x
send email plaform independently
     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*)
    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