#!/bin/bash

# pmail
# Copyright (c) 2010 Philip S Tellis
# you may use this under the terms of the BSD license available here:
# http://www.opensource.org/licenses/bsd-license.php
# (replace OWNER and YEAR with what you find in the copyright line above)

from="$USER@$(hostname)"
from_name=""
to=""
subject="pmail output"

while [ "$1" = "-f" -o "$1" = "-s" -o "$1" = "-F" ]; do
	if [ "$1" = "-f" ]; then
		from=$2
	elif [ "$1" = "-F" ]; then
		from_name=$2
	else
		subject=$2
	fi
	shift 2
done

to="$*"

( echo -e "From: $from_name <$from>\r\nSubject: $subject\r\nTo: $to\r\n\r\n"; cat ) | /usr/sbin/sendmail -t

