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 = 'me@mydomain.com';
$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: sender@mydomain.com\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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.