php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #25373 inconsistency in manual and src, possible nonstandard EOL character?
Submitted: 2003-09-02 21:23 UTC Modified: 2004-12-29 17:57 UTC
Votes:4
Avg. Score:3.8 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:3 (75.0%)
From: shane at sell dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.3 OS: linux
Private report: No CVE-ID: None
 [2003-09-02 21:23 UTC] shane at sell dot com
Description:
------------
From the PHP source (ext/standard/mail.c:215):

fprintf(sendmail, "To: %s\n", to);
fprintf(sendmail, "Subject: %s\n", subject);
if (headers != NULL) {
  fprintf(sendmail, "%s\n", headers);
}
fprintf(sendmail, "\n%s\n", message);

From the manual (http://us4.php.net/manual/en/function.mail.php):

Note:  You must use \r\n to separate headers, although some Unix mail transfer agents may work with just a single newline (\n).

The source and the manual seem to differ in their treatment of newlines.

We were alerted to this problem by a customer's mail server, which is having trouble parsing "\r\n" (which is the RFC standard, right?).

Expected result:
----------------
550 error on remote SMTP server


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-09 02:53 UTC] jhaar at trimble dot co dot nz
This reference to <CR><LF> is causing grief.

That is a reference to the SMTP RFCs - not "how to write text to a command-line mailer like /usr/sbin/sendmail".

As mail() calls the command-line program, it should refer to EOL as being "<LF>" only. 

It so happens that sendmail converts <CR><LF> it sees in text into <LF> before processing it any further - but that was a wee sendmail-specific feature - not an official standard.

e.g. Qmail has a "sendmail clone" /usr/sbin/sendmail - and it *doesn't* do that. Then you end up with e-mail going out with <CR><CR><LF> within the SMTP transaction - yuck!

Thanks

Jason
 [2004-04-08 05:23 UTC] Jon at cytekstudios dot com
Ive also had that issue, because the manual indicates to use \r\n. I just removed the \r and everything worked fine. 
Maybe we could just change the manual entry to only have the \n's? Does using only \n's create problems with other mailers or OS's? I've only tested on linux with qmail. 

Thanks,
Jonathan
CytekStudios.com
 [2004-07-02 13:23 UTC] php at grandrath-net dot de
I experienced the very same issue with exim. Replacing '\r\n' with '\n' and removing any linebreak from the last header-line did the trick.

Please update your documentation. THX!

Martin Grandrath
 [2004-07-02 13:37 UTC] vrana@php.net
AFAIK \r\n has to be on Windows, \n on Unix (even it may work sometimes with \r\n as explained by "jhaar at trimble dot co dot nz"). I don't know what's correct on Mac.

I wish to change this in php-src to work same on all platforms rather than documenting it.
 [2004-07-02 17:49 UTC] curt@php.net
All Command should issue <CRLF>, According to rfc821 4.1.1 and rfc2821 2.3.7. sendmail might be taking care of the actual translations, but either way, its probably a bad idea to send mixed line endings in the smtp commands.


 [2004-12-29 17:57 UTC] mez@php.net
This has now been changed to:

Note:  You must use \r\n to separate headers, although some Unix mail transfer agents replace \n by \r\n automatically (leads to doubling \r if \r\n is used).

Which should be sufficent documentation on this issue.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 29 12:01:30 2024 UTC