2
votes

The following header informations I have added to send a html content as a mail message.

$headers = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'Content-type: multypart/mixed; boundary=\'PHP-mixed'."\r\n";

$headers .= "Content-Transfer-Encoding: 8bit"."\r\n";

$headers .= "Content-Type: application/pdf; name=/home/sugumar/LOGO2.jpg"."\r\n";

mail($to, $subject, $message, $headers);

In the HTML body tag has image tag. but in mail the image is not shown. how to send the image with mail. I don't want as a attachment. its like a inline content.

1
Where are you actually adding the image file to the E-Mail? Using a local path won't do. And note a typo in multipart... The standard answer to this would be use a ready-made mailing class like Swiftmailer.Pekka

1 Answers

3
votes

You need to include the image as an attachment if you want it inline.

What you do is in your HTML, instead of putting <img src="filename.jpg" />, you put the Content-ID of the image, i.e, <img src="cid:$cid" />

This article has a better breakdown with a working example:

http://www.phpeveryday.com/articles/PHP-Email-Using-Embedded-Images-in-HTML-Email-P113.html