#!/bin/bash
m() {
to_addr="$1"
cc_addr="$2"
subject="$3"
body="$4"
cat "$body" | mail -s "$subject" -c "$cc_addr" "$to_addr"
}
if [[ "$#" -eq 4 ]]; then
m "$1" "$2" "$3" "$4"
else
echo "Incorrect number of paramaters. Aborting."
echo "Example syntax: $0 [email protected] [email protected] "Message Subject" /path/to/messagebody.txt"
exit 1
fi