我使用file_get_contents()
讓我的網頁,並通過電子郵件發送給用戶如何將使用file_get_contents()獲取的圖像附加到電子郵件?
我以這種方式使用它:
$html=file_get_contents($path);
,並將其與圖像一起帶來的網頁,但是當我用它發送電子郵件,它不會發送圖像。
我的代碼如下所示。我在開始時定義了$path
,並且它工作得很好。
$html =file_get_contents($path);
$file = $path;
$crlf = "\r\n";
$hdrs = array(
"From" => "[email protected]********.com",
"Subject" => "Nice to meet you"
);
$mime = new Mail_mime($crlf);
$mime->setTXTBody($text);
$mime->addHTMLImage ($file, "images/jpeg");
$mime->setHTMLBody($html);
$body = $mime->get();
$hdrs = $mime->headers($hdrs);
$mail =& Mail::factory("mail");
$mail->send($contact_email, $hdrs, $body);
我收到一封電子郵件,文本和CSS但圖像沒有得到加載
您是否在html/css中使用服務器上圖像的絕對路徑?這些圖像不會通過file_get_contents下載到「email」中。 –
這不是因爲您的電子郵件客戶端阻止了圖像的顯示,是嗎? – andrewsi
沒有我使用相對路徑 –