Martineau
Part of the Furniture
If usingPerfect! Good job!
I'm struggling with attaching the png to email, or at least puting it in-line.
div-email.sh
try changing
Code:
mailbody=$2
Code:
mailbody=$2
mailpng=$3 # Martineau Hack
and replace
Code:
echo " $(cat $mailbody)" >>/tmp/mail.txt
Code:
if [ -n "$mailpng" ] && [ -f "$mailpng" ];then # Martineau Hack
echo "MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=\"MULTIPART-MIXED-BOUNDARY\"
--MULTIPART-MIXED-BOUNDARY
Content-Type: multipart/alternative; boundary=\"MULTIPART-ALTERNATIVE-BOUNDARY\"
--MULTIPART-ALTERNATIVE-BOUNDARY
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline" >>/tmp/mail.txt
fi
cat $mailbody >>/tmp/mail.txt
if [ -n "$mailpng" ] && [ -f "$mailpng" ];then # Martineau Hack
# PNG
echo "--MULTIPART-ALTERNATIVE-BOUNDARY--
--MULTIPART-MIXED-BOUNDARY
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"$mailpng\"" >>/tmp/mail.txt
# convert .png to base64 and append to the upload file
cat $mailpng | openssl base64 >>/tmp/mail.txt # Martineau Hack
# end of uploaded file
echo "--MULTIPART-MIXED-BOUNDARY--" >>/tmp/mail.txt # Martineau Hack
fi
then you can optionally additionally specify which PNG you wish to attach
e.g.
Code:
/jffs/addons/vnstat.d/div-email.sh "Warning" /tmp/report.txt /tmp/var/wwwext/vnstat/vnstat.png
Last edited: