php.net |  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
Votes:4
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
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: as at as dot hu
New email:
PHP Version: OS:

 

 [2007-06-18 20:32 UTC] as at as dot hu
Description:
------------
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 http://pobox.com/~djb/docs/smtplf.html.,



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

Expected result:
----------------
The email bounce to the sender from some hosts. (like citromail.hu, vipmail.hu) with this error message:
http://pobox.com/~djb/docs/smtplf.html

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";
$row=mysql_fetch_array($result);
$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);
mail($to,$subject,$body,$headers);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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:
ashutest(at)vipmail.hu

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

Please read http://www.faqs.org/rfcs/rfc822.html


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 = mail.xxx.hu
smtp_port = 25

; For Win32 only.
sendmail_from = return(at)xxx.hu

; 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] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 [2007-06-22 17:41 UTC] as at as dot hu
thanks. 
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: Sat Jan 29 02:03:33 2022 UTC