PHP使用mail函数发送邮件标题乱码的问题
点击次数:109 次 发布日期:2008-10-28 09:42:19 作者:源代码网
|
源代码网推荐
源代码网整理以下PHP程序使用mail()函数发送邮件的时候,标题中文的话会出现乱码。
源代码网整理以下解决方法:
源代码网整理以下先用函数base64_encode() — 使用 MIME base64 对数据进行编码
源代码网整理以下标题字符串前加编码类型例如: =?UTF-8?B?
源代码网整理以下标题字符串后加:?=
源代码网整理以下邮件header说明Content-type — 防止邮件正文也乱码
源代码网整理以下举例:
源代码网整理以下
| 以下为引用的内容:
源代码网整理以下 $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);
|
源代码网供稿. |