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