因此,电子邮件内容的编码工作,但主题的编码没有。我尝试过不同类型的编码,但它们似乎不起作用..请帮帮我。
所以我收件箱中的内容是“ššuūūuķ&#31”作为主题,一切都在电子邮件的内容中正常工作。
$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);
答案 0 :(得分:1)
您需要对法语字符进行编码。试试这个:
$subject = utf8_encode($_POST['sub']);
或编码标题
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
答案 1 :(得分: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);