Unix sendmail - html embed image not working -


with prior posts in so.com have tried building script send email outlook account image inline in email body. html contents getting displayed in html rather displaying image. please help.

here snippet

{ echo "to: xxx@yyy.com" echo "from: test_image@yyy.com>" echo "subject: embed image test" echo "mime-version: 1.0" echo "content-type: multipart/related;boundary="--xyz""  echo "--xyz" echo "content-type: text/html; charset=iso-8859-15" echo "content-transfer-encoding: 7bit" echo "<html>" echo "<head>" echo "<meta http-equiv="content-type" content="text/html; charset=iso-8859-15">" echo "</head>" echo "<body bgcolor="#ffffff" text="#000000">" echo "<img src="cid:part1.06090408.01060107" alt="">" echo "</body>" echo "</html>"   echo "--xyz" echo "content-type: image/jpeg;name="sathy.jpg"" echo "content-transfer-encoding: base64" echo "content-id: <part1.06090408.01060107>" echo "content-disposition: inline; filename="sathy.jpg"" echo $(base64 sathy.jpg) echo "' />" echo "--xyz--" }| /usr/lib/sendmail -t 

email received contains below rather displaying image,

--xyz content-type: text/html; charset=iso-8859-15 content-transfer-encoding: 7bit <html> <head> <meta http-equiv=content-type content=text/html </head> <body bgcolor=#ffffff text=#000000> <img src=cid:part1.06090408.01060107 alt=> </body> </html> --xyz content-type: image/jpeg;name=sathy.jpg content-transfer-encoding: base64 content-id: <part1.06090408.01060107> content-disposition: inline; filename=sathy.jpg /9j/4qayrxhpzgaasukqaagaaaaaaaaaaaaaap/sabfedwnreqabaaqaaaaoaad/4qnxahr0cdov ....base64 values..... /> --xyz-- ----xyz-- 

can please assist me in missing

the way use echo print message headers eats double quotes - need escape them backslash (\") make work.

also, boundary wrong. if define boundary=--xyz, each message part needs start ----xyz (you need add 2 dashes), otherwise boundary should xyz. , headers of mime parts must separated bodies empty line.

if need generate mail shell script, advise rid of echo , use heredoc instead:

sendmail -t <<eot to: xxx@yyy.com from: <test_image@yyy.com> subject: embed image test mime-version: 1.0 content-type: multipart/related;boundary="xyz"  --xyz content-type: text/html; charset=iso-8859-15 content-transfer-encoding: 7bit  <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-15"> </head> <body bgcolor="#ffffff" text="#000000"> <img src="cid:part1.06090408.01060107" alt=""> </body> </html>  --xyz content-type: image/jpeg;name="sathy.jpg" content-transfer-encoding: base64 content-id: <part1.06090408.01060107> content-disposition: inline; filename="sathy.jpg"  $(base64 sathy.jpg) --xyz-- eot 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -