0

因此,电子邮件内容的编码有效,但主题的编码无效。我尝试了不同类型的编码,但它们似乎不起作用..请在这里帮助我。

因此,我在收件箱中收到的是“šuūūuķ”作为主题,并且在电子邮件的内容中一切正常。

$subject = $_POST['sub'];

$headers = "From: $name <$from>\nReply-To:$from\nReturn-Path:$from\nX-Mailer: PHP\n";
$limite = "_parties_".md5 (uniqid (rand()));
$headers .= "Date: ".date("l j F Y, G:i")."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1"."\n";
$headers .= " boundary=\"----=$limite\"\n\n";

$message = '<html><body><table>';
$message .= '<tr>';
$message .= '<td colspan=2>'.$email_message.'</td>';
$message .= '</tr>';
$message .= '<tr>';
$message .= '<td height=10 colspan=2>'.$irack_id.'</td>';
$message .= '</tr>';
$message .= '</table>';
$message .= '</body>';
$message .= '</html>';

mail($to, $subject, $message, $headers);
4

2 回答 2

2

您需要对法语字符进行编码。尝试这个:

$subject = utf8_encode($_POST['sub']);

或对标头进行编码

$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
于 2013-10-31T01:33:31.730 回答
0

https://ncona.com/2011/06/using-utf-8-characters-on-an-e-mail-subject/

$to = 'example@example.com';
$subject = 'Subject with non ASCII ó¿¡á';
$message = 'Message with non ASCII ó¿¡á';
$headers = 'From: example@example.com'."\r\n"
.'Content-Type: text/plain; charset=utf-8'."\r\n";
mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers);
于 2017-03-10T15:11:21.540 回答