0

I am trying to send an email with a picture; the body of my email is:

<?php 

$message = <<< email

<img src="http://planet-earth.bogus.us/icons/secret.pictures.gif">

Dear {$email},

email;

?>

When I receive the email, I can't see the picture. Instead, I see <img src="http://planet-earth.bogus.us/icons/secret.pictures.gif">. I know it's because of the <<< email; how would I be able to display the picture instead of the code using <<< email?

UPDATE

I am using zend-framework. My code looks like this:

<?php
     $mail = new Zend_Mail();
     $mail->setFrom('admin@mysite.com', 'My site');
     $mail->addTo($recoveryaccount->username);
     $mail->setSubject("Mysite");
     include "_email_recover_password.phtml";
     $mail->setBodyText($message);
     $mail->send();
?>

_include "_email_recover_password.pthml" 
<?php 

 $message = <<< email
 <img src="http://picturelocation.picture.gif">
 Dear {$account->getUsername()},

 Somebody has requested that the password associated with this account be
 reset. If you initiated this request, click the below link to complete the process:

 http://www.example.com/{$account->getRecovery()}

 Thank you!
 Mysite

 Questions? Contact us at admin@mysite.com

 email;

 ?>
neminem
  • 2,658
  • 5
  • 27
  • 36
user1347693
  • 15
  • 2
  • 3
  • 7
  • 1
    No, it actually has nothing to do with the `<<< email` and more to do with your content type. Can you show the code where you send the e-mail please? – Ry- Apr 21 '12 at 00:53

3 Answers3

6

To answer your question, you need to send out content headers that sets the content type to text\html. Without it, your message is treated as plain text by the receiving client. The following code sets the content headers properly and sends out a basic HTML message.

// message
$message = '
<html>
<body>
  <img src="http://planet-earth.bogus.us/icons/secret.pictures.gif">
</body>
</html>
';

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

$headers .= 'To: David <david-z@domain.com>' . "\r\n";
$headers .= 'From: Bot <bot@domain.com>' . "\r\n";

mail("david-z@domain.com", "mysubject", $message, $headers);
David Z.
  • 5,621
  • 2
  • 20
  • 13
1

No, it's not because of the heredoc. You need to send a properly formatted HTML mail, which you aren't. There's various headers and MIME 'skeleton' structural stuff that you're not sending at all.

Don't try to build one yourself. Use Swiftmailer or PHPMailer to do that for you.

Marc B
  • 356,200
  • 43
  • 426
  • 500
-1

What i use ,

$from="From: TEST\r\nMIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1"; 
mail("TOWHO@TEST.com", $title, $content, $from); 
Kevin
  • 41,694
  • 12
  • 53
  • 70
  • Welcome to Stack Overflow! While this code may answer the question, providing additional context regarding *why* and/or *how* this code answers the question improves its long-term value. – Benjamin W. Mar 29 '16 at 03:32