分类: LINUX
2011-01-27 13:41:24
$subject = stripslashes($the_post['Title']);
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=utf-8\r\n";
$headers .= "Content-Transfer-Encoding: 8bit\r\n";
$message = stripslashes(strip_tags($the_post['Content']));
mail($to, $subject, $message, $headers);
先用函数base64_encode() — 使用 MIME base64 对数据进行编码
标题字符串前加编码类型例如: =?UTF-8?B?
标题字符串后加:?=
例如:
$subject = "=?UTF-8?B?".base64_encode($subject)."?=";
将上面一句添加到代码之中,这样,发送的中文邮件标题就不是乱码了。