Jump to content

Adding an inlineimage into a text EMail


bag

Recommended Posts

Guys,

 

I want to send an inline image with an EMail.  basically a logo at the top in a text email.

 

I've recieved a few so I know it can be done but when I do it I get the filename printed underneath and the picture is clickable.    This doesn't happen with the others.  Any ideas?

 

Here is my code whech send the Eail OK.

 

$mail_logo = 'Picture.jpg';

$to = '[email protected]';
$subject = 'EMail with header'; 

$file = fopen($mail_logo,'rb');
$data = fread($file,filesize($mail_logo));
fclose($file);
$data = chunk_split(base64_encode($data));

$headers = "From: [email protected]\r\nReply-To: sender@mydomain\r\n";
$headers .= "MIME-Version: 1.0\r\n"; 

$boundary = md5(uniqid(time()));

$headers .= "Content-Type: multipart/mixed; boundary = $boundary\r\n\r\n"; 

$message = "--$boundary\r\n";
$message .= "Content-Type: image/jpg;\n name=\"{$mail_logo}\"\n";
$message .= "Content-Disposition: related;\n filename=\"{$mail_logo}\"\n";
$message .= "Content-Transfer-Encoding: base64\n\n";
$message .= "$data\n\n";

$message .= "--$boundary\r\n";
$message .= "Content-Type: text/plain; charset=ISO-8859-1\n";

$message .= "\n\nThis is the plain text line\nand line 2"; 

$mail_sent = @mail( $to, $subject, $message, $headers );

 

 

Link to comment
https://forums.phpfreaks.com/topic/195150-adding-an-inlineimage-into-a-text-email/
Share on other sites

Have you looked at the source of the mails that you have received? Doing that may give you clues how it is done. I suspect it might be something to do with your client, but if the others you have received show it correctly, then it cannot be that. :-)

 

Maybe you post the answer back here to help others, when you have found it?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.