IAM發送HTML郵件包含表發送HTML格式的電子郵件
當我recive消息在Gmail,Hotmail服務,雅虎帳戶它工作正常,但其他客戶端在接收時 如微軟的Outlook它解決它作爲html代碼!
這裏是我的電子郵件標題
'MIME-Version: 1.0' . "\r\n" .
'Content-Type: text/html;charset= UTF-8' . "\r\n" .
'From: me <[email protected]>'
IAM發送HTML郵件包含表發送HTML格式的電子郵件
當我recive消息在Gmail,Hotmail服務,雅虎帳戶它工作正常,但其他客戶端在接收時 如微軟的Outlook它解決它作爲html代碼!
這裏是我的電子郵件標題
'MIME-Version: 1.0' . "\r\n" .
'Content-Type: text/html;charset= UTF-8' . "\r\n" .
'From: me <[email protected]>'
我始終使用該功能,它可以幫助
function sendHTMLemail($HTML,$from,$to,$subject,$fromname)
{
$headers = "From: ".$fromname." <".$from.">\r\n";
$headers.= "Reply-To: ".$fromname." <".$from.">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$boundary = uniqid("HTMLEMAIL");
// First we be nice and send a non-html version of our email
$headers .= "Content-Type: multipart/alternative;".
"boundary = $boundary\r\n\r\n";
$headers .= "This is a MIME encoded message.\r\n\r\n";
$headers .= "--$boundary\r\n".
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode(strip_tags($HTML)));
// Now we attach the HTML version
$headers .= "--$boundary\r\n".
"Content-Type: text/html; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($HTML));
// And then send the email ....
mail($to,$subject,"",$headers);
}
我用這個函數把faield這個例子的味精--HTMLEMAIL4fb3a5e273c28 Content-Type:text/plain;字符集= ISO-8859-1 內容傳送編碼:BASE64 CgoJCgkJCgkKCQoJCQoKCQkJCgkJCQoJCQkJCgkJCQoKCQkJCgkJCQoJCQkJCgkJCQkJCgkJCQkJ CU5hbWUgOiBTYW15Q29tcGFueSBOYW1lOiBzYW15RW1haWwgOnNhbXltYXNzb3VkQGdtYWlsLmNv bVRlbGVwaG9uZSA6MDEwMDMzMzMzMUZheDogQ291bnRyeTogRUdZUFRUb3BpYzogUGF5cm9sbCBz ZXJ2aWNlc01lc3NhZ2UgOkhlbGxvCQkJCQkKCQkJCQoJCQkKCgkJCQoJCQkKCQkJCQoJCQkJCXd3 dy5wcmVtaWVyZWd5cHQuY29tIAoJCQkJCUNsaWNrIGhlcmUgdG8gdW5zdWJzY3JpYmUgZnJvbSB0 aGlzIGVtYWlsIG5vdGlmaWVyCgkJCQkKCQkJCgoJCQ –
我知道這是不是你的問題的答案,但我建議使用一個郵件圖書館,這將允許您更容易地發送郵件,並支持附件,身份驗證等功能。
我推薦SwiftMailer,它工作的很棒,很簡單並且有很好的文檔記錄。
您是否檢查過客戶端顯示爲HTML而不是純文本? – Menztrual
已檢查,我無法找到任何選項加上這是收件箱中的郵件頭Content-Type:text/html; charset = UTF-8 From:premieregypt.com <[email protected]> 回覆:me <[email protected]> Message-Id:<[email protected]> Date:Wed,16 May 2012 12:19:02 +0200(CEST) –
你有沒有其他基於HTML的電子郵件在Outlook中正確顯示? – vimist