在邮件 php 中嵌入图像
我正在尝试为我的网络杂志发送时事通讯。我的 PHP 代码是:
$to = $allEmails[$i];
$subject = $sub;
$message = $msg;
//$message .= '<p>To unsubscribe , click here <a href="http://www.7sisters.in/index.php?menu=unsubscribe&email='.$to.'">Unsubscribe</a></p>';
$message .= '<br />To unsubscribe , click here ';
$message .= "http://www.7sisters.in/index.php?menu=unsubscribe&email=".$to;
$message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
$message = stripcslashes($message);
$from = $from_mail;
//$headers = "From:" . $from;
$headers = "From:" . $from . "\r\n" .
"Reply-To:" . $from . "\r\n" .
"X-Mailer: PHP/" . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
mail($to,$subject,$message,$headers);
我按照教程 http://css -tricks.com/2866-sending-nice-html-email-with-php/ 在该邮件中嵌入图像。但邮件中没有显示图像!
I am trying to send newsletter for my web magazine . My PHP code is :
$to = $allEmails[$i];
$subject = $sub;
$message = $msg;
//$message .= '<p>To unsubscribe , click here <a href="http://www.7sisters.in/index.php?menu=unsubscribe&email='.$to.'">Unsubscribe</a></p>';
$message .= '<br />To unsubscribe , click here ';
$message .= "http://www.7sisters.in/index.php?menu=unsubscribe&email=".$to;
$message .= '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';
$message = stripcslashes($message);
$from = $from_mail;
//$headers = "From:" . $from;
$headers = "From:" . $from . "\r\n" .
"Reply-To:" . $from . "\r\n" .
"X-Mailer: PHP/" . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
mail($to,$subject,$message,$headers);
I followed the tutorial http://css-tricks.com/2866-sending-nice-html-email-with-php/ to embed images within that mail . But the image is not showing within the mail !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
Try this
你应该看到这篇文章:
在邮件 php 中嵌入图像
许多客户端/浏览器最初不会下载图像。如果您想要更好的体验,您应该按照该问题中的讨论将其包含在内来嵌入它。
这里也有一个很好的教程:
http://www.litfuel.net/tutorials/mail2.htm
you should see this post:
Embed images within mail php
A lot of clients/browsers will not download images initially. If you want a better experience, you should embed it by including it as discussed in that question.
A good tutorial here too:
http://www.litfuel.net/tutorials/mail2.htm