use*_*693 0 php email zend-framework sendmail image
我正在尝试发送带有图片的电子邮件; 我的电子邮件正文是:
<?php
$message = <<< email
<img src="http://planet-earth.bogus.us/icons/secret.pictures.gif">
Dear {$email},
email;
?>
Run Code Online (Sandbox Code Playgroud)
当我收到电子邮件时,我看不到图片.相反,我明白了<img src="http://planet-earth.bogus.us/icons/secret.pictures.gif">.我知道这是因为<<<电子邮件; 如何使用<<<电子邮件显示图片而不是代码?
UPDATE
我正在使用zend-framework.我的代码看起来像这样:
<?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;
?>
Run Code Online (Sandbox Code Playgroud)
要回答您的问题,您需要发送设置内容类型的内容标题text\html.没有它,接收客户端会将您的消息视为纯文本.以下代码正确设置内容标头并发送基本HTML消息.
// 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);
Run Code Online (Sandbox Code Playgroud)