php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7629 Mail() fails when the email message has a "\n"
Submitted: 2000-11-03 17:16 UTC Modified: 2002-06-08 10:17 UTC
From: smiglio at newtek dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.3pl1 OS: W2000 Server
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: smiglio at newtek dot com
New email:
PHP Version: OS:

 

 [2000-11-03 17:16 UTC] smiglio at newtek dot com
Works under Linux but not under W2000 Server.

Function : Mail()

When i put a \n in the email message, the mail() function fails.

if i send the same email without any \n it's working.

I only have this problem under Windows 2000 server 
(i never try under W98 or another microsoft OS)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-09 07:46 UTC] cynic@php.net
you have to use \r\n in messages mail()ed from win32 systems. I don't know whether this can be considered as the correct behavior.
 [2001-01-09 07:59 UTC] hholzgra@php.net
SMTP defines line ending as CR LF (\r\n)
also some SMTP servers will also accept LF (\n)

the SMTP code for mail() on windows should 
take care of this ...

moved to feature requests
 [2001-01-09 14:19 UTC] vlad@php.net
Are you sure it should be a feature request, and not closed? I remember reading that \r\n is the *only* valid line ending, at least for headers, and something similar for body... (looked it up - RFC822 Section 3.2, also 3.1.4, and others. 3.3 implies that a single LF should *not* be used, as far as I can interpret)

If some servers accept \n by itself, they do not seem to be RFC-compliant, do we really want to change the way mail() works to support non-compliant servers, or should we just put it in the documentation, and make people use \r\n instead?
 [2001-08-12 15:26 UTC] sebastian@php.net
tested on Win2K Pro using PHP-4.0.6: sending mail works with \n
 [2002-06-08 10:17 UTC] mfischer@php.net
This is fixed now in CVS, the snapshot at http://snaps.php.net/win32/php4-win32-latest.zip already contains the code which doesn't care anymore whether it's \r or \n or \r\n or \n\r in the $header, it converts it appropriately.

I haven't head yet complains about problems with \n in the $body. If so, please open a new bug report (but not if you haven't yet tested the snapshot :-)
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Jun 14 05:00:01 2026 UTC