我發現你是如何做到這一點的,你需要在郵件本身和擴展名中設置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)."?=",