在php邮件头,\r\\\<br/>或\\\<br/>中哪一行? [英] Which line break in php mail header, \r\n or \n?

查看:103
本文介绍了在php邮件头,\r\\\<br/>或\\\<br/>中哪一行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看过很多使用php邮件功能的例子。其中一些使用\r\\\
作为标题的换行符,有些使用\\\

I've seen a lot of examples using the php mail function. Some of them use \r\n as line break for the header, some use \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错了吗?

Sometimes I've had cases where \r\n is used and part of the header is interpreted by some email clients as mail text (losing these header information) - is this because \r\n is wrong?

推荐答案

CRLF \r\\ \\ n ,应根据 php文档。另外,要符合 RFC 2822 规范行必须用回车符分隔, LF \\\
之后的换行符CR \r

The CRLF \r\n, 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 \r immediately followed by the line feed, LF \n.

由于 \r\\\
是Windows平台的本机,而 \\\
到Unix,您可以使用 PHP_EOL ­文档 常量在Windows上,这是平台脚本的适当的新行字符目前正在运行。

Since \r\n is native to Windows platforms and \n 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.

这篇关于在php邮件头,\r\\\<br/>或\\\<br/>中哪一行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆