脚本宝典收集整理的这篇文章主要介绍了PHP将图像附加到电子邮件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
您需要使用addHTMLImage()方法并传递内容ID(cid),这是一个唯一的文本字符串,您还将在img的src属性中用作cid:URL.例如:
include('Mail.PHP'); include "Mail/mime.PHP"; $crlf = "\r\n"; $hdrs = array( 'From' => 'foo@bar.org','Subject' => 'Mail_mime test message' ); $mime = new Mail_mime($crlf); //attach our image wITh a unique content id $cid="mycidstring"; $mime->addHTMLImage("/path/to/myimage.gif","image/gif","",true,$cid); //Now we can use the content id in our message $html = '<html><body><img src="cid:'.$cid.'"></body></html>'; $text = 'Plain text version of email'; $mime->setTXTBody($text); $mime->setHTMLBody($html); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send('person@somewhere.org',$hdrs,$body);
以上是脚本宝典为你收集整理的PHP将图像附加到电子邮件全部内容,希望文章能够帮你解决PHP将图像附加到电子邮件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。