|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41732 Bare LFs in SMTP
Submitted: 2007-06-18 20:32 UTC Modified: 2007-06-22 17:41 UTC
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:4 (100.0%)
From: as at as dot hu Assigned:
Status: Not a bug Package: Mail related
PHP Version: 4.4.7 OS: Windows 2003
Private report: No CVE-ID: None
 [2007-06-18 20:32 UTC] as at as dot hu
On Windows 2003, default smtp server.
When I use the mail function, some target e-mail system say:
195.56.151.XX, OutboundConnectionResponse, 2007. 06. 18., 22:06:43, SMTPSVC1, AS, -, 312, 0, 47, 0, 0, -, -, 451 See,

Reproduce code:
$subject = "Elveszett jelsz?";
$headers = "From: ".$mail_pswd_from."\nX-FW-MailID:s6s06s9s80";
$to = $row['usr_email'];
$body = "Tisztelt ".$row[usr_lastname]." ".$row[usr_firstname]."!\nAz ?n jelszava: ".$row[usr_pswd]."\n\n?dv?zlettel,\nA S";

Expected result:
The email bounce to the sender from some hosts. (like, with this error message:

Actual result:
When I replace all newline to CRLF, the mail went away without problem:

$subject = "Elveszett jelsz?";
$headers = "From: ".$mail_pswd_from."\nX-FW-MailID:s6s06s9s80";
$to = $row['usr_email'];
$body = "Tisztelt ".$row[usr_lastname]." ".$row[usr_firstname]."!\nAz ?n jelszava: ".$row[usr_pswd]."\n\n?dv?zlettel,\nA S";
$body = str_replace("\r\n","\n",$body);
$body = str_replace("\r","\n",$body);
$body = str_replace("\n","\r\n",$body);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-20 12:30 UTC] bas at tobin dot nl

This is not a bug of PHP. 

E-Mail being transferred between mail servers needs CrLf (\r\n) as EOL separator. The catch however is how PHP sends the mail to your outbound mail server. On windows you always need to separate mail headers and end of lines with CrLf as this is the standard windows EOL separator. On Linux this depends on the mail injector of your Mail Server. For instance qmail expects the EOL separator to be the same as the standard linux separator Lf(\n) and when sending the message outbound converts all these Lf's to CrLf. If you feed this script with CrLf you will send E-Mail messages having extra white lines.

If your PHP script does not send the message to a typical local mail injector but to a normal inbound mail port it will have to follow RFC's and CrLf will be needed again.

So depending on your setup you either need to send CrLf or Lf between lines.
 [2007-06-20 19:51 UTC] as at as dot hu
It's a real bug. :-)
because when I use the mail function, the mail bounced from some server. It is bug.

Please try sending mail to this address:

This server is not Windows server, and MUST sending mail to this server with CrLf.

Please read

But, oK.
How to set up correctly php on windows?
In my php.ini I cannot see settings for CRLF:

[mail function]
; For Win32 only.
smtp_port = 25

; For Win32 only.
sendmail_from = return(at)

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =

When I use Wordpress, the mails not sendig for some host. Same in phpNuke, etc... So I think, it's a bug in php mail sending function.
 [2007-06-21 21:53 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

 [2007-06-22 17:41 UTC] as at as dot hu
I'm an ISP, and my users's codes don't run corectly on windows.
In my language this means it is a BUG.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Nov 27 19:03:46 2022 UTC