尝试使用PEARMail_Mime软件包,该软件包可以为您嵌入图像。
您需要使用addHTMLImage()方法并传递内容ID(cid),这是一个唯一的文本字符串,您还将在img的src属性中将其用作
cid:URL。例如:
include('Mail.php');include "Mail/mime.php";$crlf = "rn";$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);


