我见过很多使用 php 邮件功能的例子。其中一些使用 \r\n 作为标题的换行符,有些使用 \n。
$headers = "From: Just Me\n";
$headers .= "Reply-To: Just me <$email>\n";
vs
$headers = "From: Just Me\r\n";
$headers .= "Reply-To: Just me <$email>\r\n";
哪一个是正确的?
有时我遇到过使用 \r\n 并且部分标头被某些电子邮件客户端解释为邮件文本(丢失这些标头信息)的情况 - 这是因为 \r\n 是错误的吗?
CRLF\r\n
,应根据PHP 文档 http://php.net/manual/en/function.mail.php。另外,为了符合RFC 2822 http://www.faqs.org/rfcs/rfc2822.html规范行必须由回车符 CR 分隔\r
立即地随后是换行符 LF\n
.
Since \r\n
is native to Windows platforms and \n
to Unix, you can use the PHP_EOLDocs http://php.net/manual/en/reserved.constants.php#constant.php-eol constant on Windows, which is the appropriate new line character for the platform the script is currently running on.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)