mail wrapper script
This commit is contained in:
parent
be339fc77e
commit
4c1885a138
1 changed files with 39 additions and 0 deletions
39
bin/mailto
Executable file
39
bin/mailto
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
usage() {
|
||||
echo "usage: ${0} [OPTION]"
|
||||
echo
|
||||
echo "Send email from standard input"
|
||||
echo
|
||||
echo " -s SUBJECT Subject line of the message"
|
||||
echo " -t TO Email address of the recipient"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
usage
|
||||
else
|
||||
while [ $# -gt 0 ]; do
|
||||
case "${1}" in
|
||||
-s)
|
||||
SUBJECT="${2}"
|
||||
shift
|
||||
shift;;
|
||||
-t)
|
||||
TO="${2}"
|
||||
shift
|
||||
shift;;
|
||||
-h|--help)
|
||||
usage;;
|
||||
*)
|
||||
echo "ERR - \"${1}\" is not valid"
|
||||
usage;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
body=$(</dev/stdin)
|
||||
|
||||
if [ ${#body} -gt 0 ]; then
|
||||
echo "${body}" |mail -s "${SUBJECT}" ${TO}
|
||||
fi
|
Loading…
Reference in a new issue