加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

PHP Mail标头

发布时间:2020-12-13 22:05:13 所属栏目:PHP教程 来源:网络整理
导读:我的代码: $to = 'example@example.com';$subject = $_REQUEST['subject'] ;$message = $_REQUEST['message'] ;$header = "From: noreply@example.comrn"; $header.= "MIME-Version: 1.0rn"; $header.= "Content-Type: text/html; charset=ISO-8859-1r
我的代码:

$to      = 'example@example.com';
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
$header = "From: noreply@example.comrn"; 
$header.= "MIME-Version: 1.0rn"; 
$header.= "Content-Type: text/html; charset=ISO-8859-1rn"; 
$header.= "X-Priority: 1rn"; 

mail($to,$subject,$message,$header);

当我发送带有特殊字符的邮件时,例如?e-??-‘“?,?e??,
在消息中,它工作但不再处理间距(每个新行或空格被删除)
第二个问题是特殊字符不会显示在主题中.
它们输出如下:?ʼaʼ

提前致谢!

解决方法

Content-Type: text/html

如果您设置此标头意味着您必须向用户发送HTML.您可以决定使用像TinyMCE这样的东西让用户在Word样式的编辑器中编写消息并使用它的HTML输出.或者将标题设置为纯文本.

Content-Type: text/plain

编辑:试试这个

$to      = 'example@example.com';
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
$header = "From: noreply@example.comrn"; 
$header.= "MIME-Version: 1.0rn"; 
$header.= "Content-Type: text/plain; charset=utf-8rn"; 
$header.= "X-Priority: 1rn"; 

mail($to,$header);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读