1
0
mirror of https://github.com/Spearfoot/FreeNAS-scripts synced 2025-12-06 01:23:19 +00:00

Modified to fix email problems on FreeNAS 11.3

This commit is contained in:
Keith Nash
2020-03-04 17:44:35 -06:00
committed by GitHub
parent 18dcee70b5
commit 5a222759b5

View File

@@ -14,17 +14,21 @@ senddetail=0
freenashost=$(hostname -s) freenashost=$(hostname -s)
freenashostuc=$(hostname -s | tr '[:lower:]' '[:upper:]') freenashostuc=$(hostname -s | tr '[:lower:]' '[:upper:]')
boundary="===== MIME boundary; FreeNAS server ${freenashost} ====="
logfile="/tmp/ups_report.tmp" logfile="/tmp/ups_report.tmp"
subject="UPS Status Report for ${freenashostuc}" subject="UPS Status Report for ${freenashostuc}"
### Set email headers ### ### Set email headers ###
( printf "%s\n" "To: ${email}
echo "To: ${email}" Subject: ${subject}
echo "Subject: ${subject}" Mime-Version: 1.0
echo "Content-Type: text/html" Content-Type: multipart/mixed; boundary=\"$boundary\"
echo "MIME-Version: 1.0"
printf "\r\n" --${boundary}
) > ${logfile} Content-Type: text/html; charset=\"US-ASCII\"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
<html><head></head><body><pre style=\"font-size:14px; white-space:pre\">" >> ${logfile}
# Get a list of all ups devices installed on the system: # Get a list of all ups devices installed on the system:
@@ -32,7 +36,6 @@ upslist=$(upsc -l "${freenashost}")
### Set email body ### ### Set email body ###
( (
echo "<pre style=\"font-size:14px\">"
date "+Time: %Y-%m-%d %H:%M:%S" date "+Time: %Y-%m-%d %H:%M:%S"
echo "" echo ""
for ups in $upslist; do for ups in $upslist; do
@@ -77,14 +80,14 @@ upslist=$(upsc -l "${freenashost}")
done done
) >> ${logfile} ) >> ${logfile}
echo "</pre>" >> ${logfile} printf "%s\n" "</pre></body></html>
--${boundary}--" >> ${logfile}
### Send report ### ### Send report ###
if [ -z "${email}" ]; then if [ -z "${email}" ]; then
echo "No email address specified, information available in ${logfile}" echo "No email address specified, information available in ${logfile}"
else else
# sendmail -t < ${logfile} sendmail -t -oi < ${logfile}
sendmail ${email} < ${logfile}
rm ${logfile} rm ${logfile}
fi fi