php邮件标题中的哪个换行符, 或 ?
我见过很多使用 php 邮件功能的例子.其中一些使用 作为标题的换行符,一些使用 .
I've seen a lot of examples using the php mail function. Some of them use as line break for the header, some use .
$headers = "From: Just Me
";
$headers .= "Reply-To: Just me <$email>
";
对
$headers = "From: Just Me
";
$headers .= "Reply-To: Just me <$email>
";
哪一个是正确的?
有时我遇到使用 并且某些邮件客户端将部分标头解释为邮件文本(丢失这些标头信息)的情况 - 这是因为 是错误的吗?
Sometimes I've had cases where is used and part of the header is interpreted by some email clients as mail text (losing these header information) - is this because is wrong?
推荐答案
CRLF
,应该按照php 文档.此外,为了符合 RFC 2822 规范行必须由回车符分隔,CR 立即 后跟换行符,LF
.
The CRLF
, should be used according to the php documentation. Also, to conform to the RFC 2822 spec lines must be delimited by the carriage return character, CR immediately followed by the line feed, LF
.
由于
是 Windows 平台原生的,而
是 Unix 平台原生的,因此您可以使用 PHP_EOL
Docs Windows 上的常量,它是脚本当前运行平台的适当换行符.
Since
is native to Windows platforms and
to Unix, you can use the PHP_EOL
Docs constant on Windows, which is the appropriate new line character for the platform the script is currently running on.
相关文章