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