PHP发送邮件乱码的具体解决方法_PHP教程
程序员文章站
2022-05-03 12:17:45
...
我们曾经在前面一些文章中具体介绍了
下面这段代码就是PHP发送邮件乱码的具体解决方法的示例:
- ?php
- #email.php 2009-11-04
- $name = $_POST['name'];
- $mail = $_POST['mail'];
- $content = $_POST['content'];
- $subject = '测试专用';
-
$subject = "=?UTF-8?B?".
base64_encode($subject)."?="; -
$body = "来自:$mailn姓名:
$namenn内容:$content"; - $headers = "MIME-Version: 1.0rn";
-
$headers .= 'Content-type:
text/html; charset=utf-8' . "rn"; -
$headers .= "Content-
Transfer-Encoding: 8bitrn"; - if(mail('*****@qq.com',
$subject,$body,$header)){ - echo 'success';
- }else{
- echo 'fail';
- }
- ?>
希望同构对这段代码的了解,大家能避免PHP发送邮件乱码这种情况的出现。