0

I have a script like this which sends html emails. I am trying to include images into my html emails. Is this possible ? File has to use this function. I'm not looking for some quick one liner instead of my function because of file manipulations I have done in my script. When I send out emails I back a [X] instead of my image.

Email function of my script.

#!/bin/bash

Email()
{
export MAILTO="ADC@aol.com"
export CONTENT="file"
export SUBJECT="Report"
(
 echo "Subject: $SUBJECT"
 echo "To : $MAILTO"
 echo "MIME-Version: 1.0"
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 cat "$CONTENT"
) | /usr/sbin/sendmail $MAILTO
}

Email

File I am sending "file"

<html>
<body>
<img src="/home/admin/Afriendlycow.png">
</body>
</html>

I attempt to try just the file name instead of the path such as Afriendlycow.png but it does not work also.

LinA
  • 19
  • 6
  • What if you have your image web-hosted and then so long as there is a web connection the picture should go through – Adjit Oct 14 '14 at 20:14
  • That's a good idea but I don't think it's possible. Thank you for the suggestion. – LinA Oct 14 '14 at 20:24
  • It's quite possible but works poorly when recipients disable remote images. – tripleee Oct 14 '14 at 20:26
  • possible duplicate of [Embeding an image in an email using linux commands](http://stackoverflow.com/questions/14381071/embeding-an-image-in-an-email-using-linux-commands) – tripleee Oct 14 '14 at 20:32

1 Answers1

0

You are not attaching any images. A proper HTML email with images is a multipart/related containing one text/html part and one or more image/* parts. They should have a Content-Id: header with a unique identifier as its value; the HTML refers to them using <img src="cid:identifier">.

tripleee
  • 175,061
  • 34
  • 275
  • 318