Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

email - Which line break in php mail header, or ?

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>
"; 

vs

$headers = "From: Just Me
";
$headers .= "Reply-To:  Just me <$email>
";

which one is correct?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 .

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...