php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52850 The documentation is not clear enough
Submitted: 2010-09-15 11:30 UTC Modified: 2010-09-15 11:42 UTC
From: ak at ilk dot net Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ak at ilk dot net
New email:
PHP Version: OS:

 

 [2010-09-15 11:30 UTC] ak at ilk dot net
Description:
------------
In the documentation to the mail function the handling of the chars \r and \n are misleading.
The explanation  from Ben Cooke in the comments is very clear. Link to the comment: http://de.php.net/manual/en/function.mail.php#59773

It would be great to find the explanation  in the doc directly. Which would help others to find this information faster.

Here is the comment:
Note that there is a big difference between the behavior of this function on Windows systems vs. UNIX systems. On Windows it delivers directly to an SMTP server, while on a UNIX system it uses a local command to hand off to the system's own MTA. 

The upshot of all this is that on a Windows system your  message and headers must use the standard line endings \r\n as prescribed by the email specs. On a UNIX system the MTA's "sendmail" interface assumes that recieved data will use UNIX line endings and will turn any \n to \r\n, so you must supply only \n to mail() on a UNIX system to avoid the MTA hypercorrecting to \r\r\n. 

If you use plain old \n on a Windows system, some MTAs will get a little upset. qmail in particular will refuse outright to accept any message that has a lonely \n without an accompanying \r. 



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-15 11:42 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2010-09-15 11:42 UTC] aharvey@php.net
The second note within the additional_headers parameter seems to cover this already -- \r\n is the correct end of line for mail headers, and any MTA that provides a sendmail interface that can't cope with that is broken.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 01:01:28 2024 UTC