我们在使用
一般这种问题出现的原因是 mail() 函数的 header 参数里少了 content-type: text/html; charset=utf-8,或者 charset 不是utf-8。很多国外的php程序一开始开发的时候没有吧中文考虑进去,所以中文使用的时候就会出现php mail()函数乱码。
先用函数base64_encode() 使用 mime base64 对数据进行编码
标题字符串前加编码类型例如: =?utf-8?b?
当然如果是gb2312的话就 =?gb2312?b?
标题字符串后加:?=
php mail()函数乱码的处理办法举例如下
$to = 'xinple@example.com'; $subject = =?utf-8?b?.
base64_encode('邮件标题').?=; $headers = 'mime-version: 1.0' . rn; $headers .= 'content-type:
text/html; charset=utf-8' . rn; // additional headers $headers .= 'to: xinple <
xinple@example.com>' . rn; $headers .= 'from: admin <
admin@example.com>' . rn; $headers .= 'reply-to: xinple <xinple@example>' . rn; mail($to, $subject, $message, $headers);
以上就是php mail()函数乱码的具体处理办法,希望对有需要的朋友有所帮助。
http://www.bkjia.com/phpjc/446193.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/446193.htmltecharticle我们在使用 一般这种问题出现的原因是 mail() 函数的 header 参数里少了 content-type: text/html; charset=utf-8,或者 charset 不是utf-8。很多国外的php程...