试试PEAR
Mail_Mime套装,可以
embed images for you.
原文链接:https://www.f2er.com/php/133364.html您需要使用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);