问题
I have an html file under /tmp folder
as chart.html file
which will have the output like below image when you open that html file
I have a shell script that I am using to send the chart.html
file as an attachment in an email with some body message.
Problem Statement:-
Is is possible to send this colorful image of the html file(when you open it) within the body of an email? So that people can see this image in there email body, instead of opening the attachment file. Below is the command that I am using to send the attachment in an email with body message-
mailx -s "LIP Data Quality Report for $DATE_YEST_FORMAT1" -r rj@host.com rj@host.com <<EOF
Data Successfully loaded into LIP_DATA_QUALITY table
Total Items Purchased: `echo $QUERY1 | awk '{print $1}'`
Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`
Error Percentage: $QUERY2
$(uuencode /tmp/chart.html percentage_graph.html)
EOF
What changes I need to make in my above command to send this colorful image within the body itself.
回答1:
The proper way to include an image in the 21st century is with MIME. Your message should basically be something like
From: you <you@example.net>
To: recipient <victim@example.com>
Subject: well, say something
Mime-Version: 1.0
Content-type: multipart/related; boundary=foo
Often you have something about this being a MIME message here.
--foo
Content-type: text/html; charset=utf-8
Content-transfer-encoding: us-ascii
<html><yada yada><img src="cid:bar"></html>
--foo
Content-type: image/png
Content-id: bar
Content-transfer-encoding: base64
sdflkjsdflkjsdflkjsdflkjsdflksdfl=
--foo--
You can also try with a text/plain
text part and a Content-Disposition: inline
for the image; many clients will then display the image below the text.
Of course, if you already have it all in one HTML file (how? with the image?) then just attaching that with a modern MUA like mutt
should all be doable with a simple command line.
来源:https://stackoverflow.com/questions/11944124/send-the-output-of-html-file-within-the-email-body