@@ -14,25 +14,28 @@ senddetail=0
14
14
15
15
freenashost=$( hostname -s)
16
16
freenashostuc=$( hostname -s | tr ' [:lower:]' ' [:upper:]' )
17
+ boundary=" ===== MIME boundary; FreeNAS server ${freenashost} ====="
17
18
logfile=" /tmp/ups_report.tmp"
18
19
subject=" UPS Status Report for ${freenashostuc} "
19
20
20
21
# ## Set email headers ###
21
- (
22
- echo " To: ${email} "
23
- echo " Subject: ${subject} "
24
- echo " Content-Type: text/html"
25
- echo " MIME-Version: 1.0"
26
- printf " \r\n"
27
- ) > ${logfile}
22
+ printf " %s\n" " To: ${email}
23
+ Subject: ${subject}
24
+ Mime-Version: 1.0
25
+ Content-Type: multipart/mixed; boundary=\" $boundary \"
26
+
27
+ --${boundary}
28
+ Content-Type: text/html; charset=\" US-ASCII\"
29
+ Content-Transfer-Encoding: 7bit
30
+ Content-Disposition: inline
31
+ <html><head></head><body><pre style=\" font-size:14px; white-space:pre\" >" >> ${logfile}
28
32
29
33
# Get a list of all ups devices installed on the system:
30
34
31
35
upslist=$( upsc -l " ${freenashost} " )
32
36
33
37
# ## Set email body ###
34
38
(
35
- echo " <pre style=\" font-size:14px\" >"
36
39
date " +Time: %Y-%m-%d %H:%M:%S"
37
40
echo " "
38
41
for ups in $upslist ; do
@@ -77,14 +80,14 @@ upslist=$(upsc -l "${freenashost}")
77
80
done
78
81
) >> ${logfile}
79
82
80
- echo " </pre>" >> ${logfile}
83
+ printf " %s\n" " </pre></body></html>
84
+ --${boundary} --" >> ${logfile}
81
85
82
86
# ## Send report ###
83
87
if [ -z " ${email} " ]; then
84
88
echo " No email address specified, information available in ${logfile} "
85
89
else
86
- # sendmail -t < ${logfile}
87
- sendmail ${email} < ${logfile}
90
+ sendmail -t -oi < ${logfile}
88
91
rm ${logfile}
89
92
fi
90
93
0 commit comments