Save this in your path and chmod +x for a nice tiny "mail" command.
#!/bin/bash
SENDER=`whoami`
RECIPIENT=$1
shift 1
SUBJECT=$*
if test -z "$RECIPIENT"
then
echo "Missing parameters.
Usage: mail RECIPIENT SUBJECT
RECIPIENT: Target email address
SUBJECT: Mail subject
Pascal Brax - http://pascalbrax.blogspot.com
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND"
exit
fi
if test -z "$SUBJECT"
then SUBJECT="Small mail"
fi
echo To: $RECIPIENT
echo Subject: $SUBJECT
echo -n "Short message: "
read MESSAGE
BODY="To: $RECIPIENT
Subject: $SUBJECT
$MESSAGE"
echo "
Sending..."
echo "$BODY" | ssmtp $RECIPIENT
echo "Mail sent."
No comments:
Post a Comment