簡體   English   中英

使用PHP向Hotmail發送電子郵件時出現編碼問題

[英]Encoding problems when sending email with PHP to Hotmail

我使用以下代碼向我的網站成員發送電子郵件。 該腳本有效,用戶即收到電子郵件。 但是,在通過電子郵件發送到Hotmail或Notes時,我確實遇到了編碼問題。

代碼:

$to       = "to@email.com";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset="utf-8"; format="flowed"' . "\r\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n\r\n";
$headers .= "To: John Doe<john@doe.com>" . "\r\n" . 
"From: John Smith<john@smith.com" . "\r\n" .
"Reply-To: john@doe.com" . "\r\n" .
"Return-Path: john@doe.com" . "\r\n" .
"Sender: john@doe.com" . "\r\n" .
"X-Sender: john@doe.com" . "\r\n" .
"X-Mailer: JohnDoe". "\r\n".
"X-Report-Abuse: Please report abuse to: john@doe.com";

//If the e-mail was successfully sent...
$subject = $translation[104];
if(mail($to, $subject, $message, $headers)){

}

消息和主題都包含瑞典字母Å,Ä和Ö。 實際郵件已正確編碼並在Hotmail中查看,而主題則不是。 您可以查看下面的圖像以獲取更多信息:

圖片: http//www.aspkoll.se/imgo/649

我很迷惑。 我用谷歌搜索了幾天並嘗試了不同類型的解決方案,但我沒有成功,我擔心。

你能幫幫我解決這個問題嗎?

不勝感激!

電子郵件主題和其他標題內容(如名稱)使用RFC 2047進行編碼

php.net對mail()評論給出了以下示例:

mail($mail, "=?utf-8?B?".base64_encode ($subject)."?=", $message, $headers);

請嘗試http://www.phpclasses.org/browse/file/919.html 它適用於Yahoo郵件,Gmail,Hotmail。

PS:Hotmail糟透了。 :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM