Doc #63416 [Com]: WRONG STATEMENTS IN MAIL FUNCTION DOCS
| From: | jakopino at gmail dot com | Date: | Sat, 03 Nov 2012 11:48:52 +0000 |
| Subject: | Doc #63416 [Com]: WRONG STATEMENTS IN MAIL FUNCTION DOCS | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9051@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63416&edit=1
ID: 63416
Comment by: jakopino at gmail dot com
Reported by: jakopino at gmail dot com
Summary: WRONG STATEMENTS IN MAIL FUNCTION DOCS
Status: Open
Type: Documentation Problem
Package: *Mail Related
Operating System: Any
PHP Version: 5.3.18
Block user comment: N
Private report: N
New Comment:
Correct, ASCII text transmitted across the network *must* use the two-character sequence: CR LF.
But PHP behaves differently, on windows it talks directly to the mail server using SMTP protocol. In
this case it should comply with the RCF as the message travels the network.
Even more, on windows, PHP code ( in /win32/sendmail.c ) tries to distinguish various system
specific EOL cases and behaves accordingly to comply with the RFC.
On unix systems, the php mail function sends commands to the sendmail binary ( or whatever you set
as the âsendmail_pathâ in php.ini ). This is the same as typing commands on the prompt,
it *MUST* escape new lines with LF. At the end, the message will be stored in the appropriate folder
and the mail server will take care to process it correctly. Finally, the message will be sent out on
the network.
Thatâs why you should use PHP_EOL with the mail function as it is the only way to ensure
headers will terminate properly on different platforms.
I think you should remove the second note on poor quality unix smtp server ( as that is never the
case ), and change all the examples in the documentation page to reflect the correct usage of line
termination with the PHP_EOL constant ( by the way, it looks like it was introduced for the mail
function ):
Previous Comments:
------------------------------------------------------------------------
[2012-11-03 00:22:10] niel dot archer at gmail dot com
PHP does not change SMTP behaviour, it complies with it. See section 2.1 of
RFC2822 which states:
"Messages are divided into lines of characters. A line is a series of
characters that is delimited with the two characters, carriage-return
and line-feed; that is, the carriage return (CR) character (ASCII
value 13) followed immediately by the line feed (LF) character (ASCII
value 10)."
The CRLF combination in the examples tells the mail agent that those lines are
ended. It is quite legitimate to have LF characters within a line before its
end, example one does this with the $message variable.
Mail should *never* use PHP_EOL as it would break the SMTP standard.
------------------------------------------------------------------------
[2012-11-02 01:01:08] jakopino at gmail dot com
Some poor quality Unix mail transfer agents replace LF by CRLF automatically (which leads to
doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC
2822.
------------------------------------------------------------------------
[2012-11-02 00:57:58] jakopino at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.mail#refsect1-function.mail-seealso
---
PHP cannot change SMTP behavior. Newlines must be issued using the correct sequence, this sequence
must be platform independent, that's why we have the PHP_EOL constant.
It's well documented by a 7 year old thread ( https://bugs.php.net/bug.php?id=15841 ).
--------------------------------------------------------------------------
The mail function docs page is full of examples, all of them are using the windows newline sequence,
without mentioning the real problem.
Please correct that page
--------------------------------------------------------------------------
Dario Jakopec
Macro Web Media
PS Paralles Plesk Pannel 11 is using Qmail as default smtp server...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63416&edit=1