|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17801 $header can only contain header data, multilpe newlines are ignored
Submitted: 2002-06-17 10:52 UTC Modified: 2002-06-19 05:30 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: gabinunde at yahoo dot de Assigned:
Status: Closed Package: Mail related
PHP Version: CVS OS: W98, NT
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.
Block user comment
Status: Assign to:
Bug Type:
From: gabinunde at yahoo dot de
New email:
PHP Version: OS:


 [2002-06-17 10:52 UTC] gabinunde at yahoo dot de
On W98 and NT (Apache 2.0.35, PHP(as CGI) 4.1.1 and 4.2.1 tested) there is a problem sending multipart-mails:


$header has been created like at 

Until the lenght of $header is <= 4012 byte everything is working fine. Obove that limit PHP.EXE crashes (drwtsn32.log) and Apache reports: "Premature end of script headers...".

Thanks Gabi


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-17 11:06 UTC]
Several mail() problems have been fixed in the latest CVS version of PHP. Could you please try the latest non stable snapshot from
 [2002-06-18 06:38 UTC] gabinunde at yahoo dot de
First I tryed "" with PHP 4.2.2 as CGI and as module, but the same error accured with mail().

After I tryed "" with PHP 4.3.0:
-Apache works with this version only as module, not as CGI.
-Now I can send mails with $header>4012 Byte, but the plain text of the message-body as well as the attachment are received as they were headers!!!!!!!! In the source-text of the received mail message and attachment are shown in bold like all the headers (From, To, Content-Type ect...). So one can't read the message and the attachment has 0 byte.
I could send an example of such a mail.

 [2002-06-18 07:01 UTC]
Please send a script, which tries to send mail with the mail() function and produces failure output directly to me as I'm likely the one who fucked this up, thx.
 [2002-06-18 13:15 UTC]
Now that you sent me your script, I reflected the problem in the summary. The change was requested to many MTA problems which don' deal well with not-well-formed $headers.

So the current (CVS HEAD) behaviour is: Make sure whatever it is (\r, \n or \r\n) it's always \r\n (which IS required for sending over SMTP which is the case for win32) and also removing multiple \r\n occurences because they would break the header. You seem to have been used this behaviour (which isn't documented).

This can be fixed in user-space by crafting the $header carefully i.e. know where to stop and putting the rest in the $body.

I can't say anything about the BC impact here (I haven't got much feedback since the rewrite, but I think I should be happy what I got), but it seems it shouldn't be ignored.

I'm soon at the point were I'ld say I revert every change to mail() and create win32_mail_rfc_compliant() .. ;)
 [2002-06-19 05:30 UTC] gabinunde at yahoo dot de
On win32 never put message and/or attachments in the mail-header!
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Jul 23 20:01:23 2021 UTC