Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 39 lines (33 sloc) 818 Bytes
#!/bin/bash
if [ -f /root/email.cfg ]; then
source /root/email.cfg
else
echo
echo "No email configuration found (/root/email.cfg)"
echo
exit 1
fi
if [ "$1" = "" ]; then
echo
echo 'Usage: email recipient@domain.com "Subject of the email" "Body text"'
echo 'or email recipient@domain.com "Subject of the email" /path/file.ext'
echo
exit 0
fi
if [ -f "${3}" ]; then
BODY=$(cat "${3}")
else
BODY="${3}"
fi
curl -s "smtp://${MAILSERVER}:${MAILPORT}" --ssl-reqd --mail-from "${MAILFROM}"\
--mail-rcpt "${1}" --user "${MAILUSER}:${MAILPASSWORD}"\
-T <(echo -e "Subject: ${2}\n\n ${BODY}");
RC=$?
if [ ! "$RC" = "0" ]; then
echo
echo "The curl command failed: Exit code $RC"
echo
echo "Find details here: https://ec.haxx.se/usingcurl-returns.html"
echo
exit $RC
fi
You can’t perform that action at this time.