1

How do I display images in an email using the mail() function in PHP?

Does putting <img src="image path" /> work?

random
  • 9,774
  • 10
  • 66
  • 83
Shahid Karimi
  • 4,096
  • 17
  • 62
  • 104
  • Do you want to attach image with the email? or you could use any image residing on web. If the image is on Web, just use the Tag – asami May 03 '11 at 11:46
  • Right here: http://stackoverflow.com/questions/5390138/insert-image-in-mail-body – random May 03 '11 at 12:41
  • 1
    You also already posted this last week: http://stackoverflow.com/questions/5787206/php-strange-email-sending-issue – random May 03 '11 at 12:46

2 Answers2

4

You need to set the headers to tell it that it's HTML. You can do this by:

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

and then send with

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

so you pass the headers as a string to the 4th parameter of mail().

You should set the relevant character encoding in charset, and also provide a text version if this is going to end users.

Dan Blows
  • 20,846
  • 10
  • 65
  • 96
0

Try sending the mail as html. Look at this http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

Tan
  • 2,148
  • 3
  • 33
  • 54