Admin/pmail
author berghofe
Tue, 25 Mar 2003 09:47:05 +0100
changeset 13876 68f4ed8311ac
parent 13321 70a5d5fc081a
child 14034 55ba81e3502b
permissions -rwxr-xr-x
New decision procedure for Presburger arithmetic.

#!/usr/bin/env bash
#
# $Id$
# Author: Gerwin Klein, TU Muenchen
# License: GPL (GNU GENERAL PUBLIC LICENSE)
#
# DESCRIPTION: send email platform independently.

PRG="$(basename "$0")"

function usage()
{
  echo
  echo "Usage: $PRG subject recipient body"
  echo
  echo "  Send email platform independently. Body is a file."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}

## main

# argument checking

[ "$1" = "-?" ] && usage
[ "$#" != "3" ] && usage

SUBJECT="$1"
TO="$2"
BODY="$3"

[ -r "$BODY" ] || fail "could not read $BODY"

case `uname` in
    linux*|Linux*)
    mail -s "$SUBJECT" "$TO" < "$BODY"
    ;;

    SunOS*)
    mail -t "$TO" <<EOF
Subject: $SUBJECT

`cat $BODY`
EOF
    ;;

    *)  
    fail "unkown platform"
    ;;
esac