php邮件标题中的哪个换行符, 或 ? [英] Which line break in php mail header, or ?

查看:19
本文介绍了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.

这篇关于php邮件标题中的哪个换行符, 或 ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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