Admin/pmail
changeset 13320 2c6ee189ae63
child 13321 70a5d5fc081a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Admin/pmail	Tue Jul 09 11:46:36 2002 +0200
     1.3 @@ -0,0 +1,56 @@
     1.4 +#!/usr/bin/env bash
     1.5 +#
     1.6 +# $Id$
     1.7 +# Author: Gerwin Klein, TU Muenchen
     1.8 +# License: GPL (GNU GENERAL PUBLIC LICENSE)
     1.9 +#
    1.10 +# DESCRIPTION: send email platform independently.
    1.11 +
    1.12 +PRG="$(basename "$0")"
    1.13 +
    1.14 +function usage()
    1.15 +{
    1.16 +  echo
    1.17 +  echo "Usage: $PRG subject recipient body"
    1.18 +  echo
    1.19 +  echo "  Send email platform independently. Body is a file."
    1.20 +  echo
    1.21 +  exit 1
    1.22 +}
    1.23 +
    1.24 +function fail()
    1.25 +{
    1.26 +  echo "$1" >&2
    1.27 +  exit 2
    1.28 +}
    1.29 +
    1.30 +## main
    1.31 +
    1.32 +# argument checking
    1.33 +
    1.34 +[ "$1" = "-?" ] && usage
    1.35 +[ "$#" != "3" ] && usage
    1.36 +
    1.37 +SUBJECT=$1
    1.38 +TO=$2
    1.39 +BODY=$3
    1.40 +
    1.41 +[ -r $BODY ] || fail "could not read $BODY"
    1.42 +
    1.43 +case `uname` in
    1.44 +    Linux*)
    1.45 +    mail -s "$SUBJECT" $TO <$BODY
    1.46 +    ;;
    1.47 +
    1.48 +    SunOS*)
    1.49 +    mail -t $TO <<EOF
    1.50 +Subject: $SUBJECT
    1.51 +
    1.52 +`cat $BODY`
    1.53 +EOF
    1.54 +    ;;
    1.55 +
    1.56 +    *)  
    1.57 +    fail "unkown platform"
    1.58 +    ;;
    1.59 +esac