2013-04-27 86 views
0

我試圖閱讀這個問題和檢查的例子,但沒有找到一種方法來解決這個問題。當我的確認信被髮送給買方/賣方時,ÅÄÖ或其他特殊字符將被破壞,我該如何改變?下面是截圖:http://snag.gy/7IFDQ.jpgPHP PayPal IPN和UTF-8

正如你可以看到文本和主題都已損壞。

我當然在PayPal配置文件中更改爲utf-8。這是別的。我在很長一段時間後找到了解決PDT問題的方法,但現在「同樣的」問題在IPN方面給我帶來了麻煩。

任何人都知道如何完全解決這個問題?如果你想要,我可以粘貼IPN.php和Ipnhandler。

回答

0

我發現你是如何做到這一點的,你需要在郵件本身和擴展名中設置UTF-8(郵件主題等)以及郵件中的郵件。

繼承人發送郵件到customr及複印件給賣家一個代碼示例:

// send user an email with a confirmation 
    $firstname = $_POST['first_name']; 
    $lastname = $_POST['last_name']; 
    $to = filter_var($_POST['payer_email'], FILTER_SANITIZE_EMAIL); 
    $to2 = filter_var($_POST['[email protected]'], FILTER_SANITIZE_EMAIL); 
    $subject = "Tack för Ert köp!/Thank you for your order!"; 
    $subject2 = "(COPY) Tack för Ert köp!/Thank you for your order!"; 
    $headerFields = array(
    'Date: ' . date('r', $_SERVER['REQUEST_TIME']), 
    "Subject: =?UTF-8?Q?".imap_8bit($subject)."?=", 
    "From: {$to}", 
    "MIME-Version: 1.0", 
    "Content-Type: text/html;charset=utf-8" 
    ); 
    $headerFields2 = array(
    'Date: ' . date('r', $_SERVER['REQUEST_TIME']), 
    "Subject: =?UTF-8?Q?".imap_8bit($subject2)."?=", 
    "From: {$to}", 
    "MIME-Version: 1.0", 
    "Content-Type: text/html;charset=utf-8" 
    ); 
    $message = "$firstname $lastname, $payer_email <br /> 
MESSAGE TO CUSTOMER; 
    $message2 = "$firstname $lastname, $payer_email <br /> 
MESSAGE TO CUSTOMER 
(NOTE: THIS IS A COPY)"; 
    mail($to, $subject, $message, implode("\r\n", $headerFields)); 
    mail($to2, $subject2, $message2, implode("\r\n", $headerFields2)); 
    } 

正在發生的事情是,$ headerFields "MIME-Version: 1.0", "Content-Type: text/html;charset=utf-8"套UTF-8的郵件的消息。它甚至適用於標題除外,需要單獨設置爲:"Subject: =?UTF-8?Q?".imap_8bit($subject)."?=",