php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32228 broken email with attachments
Submitted: 2005-03-08 01:53 UTC Modified: 2005-03-08 10:43 UTC
From: vlada dot misic at service24 dot at Assigned:
Status: Not a bug Package: Mail related
PHP Version: 4.3.9 OS: w2k/xp/win 2003
Private report: No CVE-ID: None
 [2005-03-08 01:53 UTC] vlada dot misic at service24 dot at
Description:
------------
The problem is that mail function does not parse correct parameters when sending emails. It does not prints out all new line characters which are sent in the header.

I marked those missing \n in the example.

I also found the same problem here http://aspn.activestate.com/ASPN/Mail/Message/php-windows/2508303

I made a lot of tests and seem to be general problem on any windows platform or version of PHP. When I open the source of broken email and just add those four missing \n in the ascii editor the email becomes correct and attacment also.

I also noticed that all \n chars missing in the message body. So I think it is general problem with \n chars in the process of generating email message.

Reproduce code:
---------------
$header    .= "Content-Type: multipart/mixed; boundary=$uid\n\n";
$header    .= "--$uid\n";
$header    .= "Content-Type: text/plain;\n";
$header    .= "\t";
$header    .= "charset=\"iso-8859-1\"\n";
$header    .= "Content-Transfer-Encoding: quoted-printable\n\n"; //the second \n is missing
$header    .= "$message\n\n"; //the second \n is missing
$header    .= "--$uid\n";
$header    .= "Content-Type: application/msword;\n";
$header    .= "\t";
$header    .= "name=\"invoice.doc\"\n";
$header    .= "Content-Transfer-Encoding: base64\n";
$header    .= "Content-Disposition: attachment;\n";
$header    .= "\t";
$header    .= "filename=\"invoice.doc\"\n\n"; //the second \n is missing
$invoice	= chunk_split(base64_encode($invoice));
$header    .= "$invoice\n\n"; //the second \n is missing
$header    .= "--$uid\n";


Expected result:
----------------
Content-Type: multipart/mixed; boundary=_NextPart_5901498AE5B7167A32D274DEED0E3965
Return-Path: me@localhost.com
Message-ID: <SAMMYoUH8qwpEWZ1Aeh00000004@sammy>
X-OriginalArrivalTime: 08 Mar 2005 00:06:57.0578 (UTC) FILETIME=[BE4B58A0:01C52372]

--_NextPart_5901498AE5B7167A32D274DEED0E3965
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Some content - first line

some content - third line (one is empty)

--_NextPart_5901498AE5B7167A32D274DEED0E3965
Content-Type: application/msword;
	name="invoice.doc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="invoice.doc"

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAACAAAApwAAAAAAAAAA
...... !!!! not complete attachment since it is irrelevant !!!! .....
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=

--_NextPart_5901498AE5B7167A32D274DEED0E3965


Actual result:
--------------
Content-Type: multipart/mixed; boundary=_NextPart_5901498AE5B7167A32D274DEED0E3965
Return-Path: me@localhost.com
Message-ID: <SAMMYoUH8qwpEWZ1Aeh00000004@sammy>
X-OriginalArrivalTime: 08 Mar 2005 00:06:57.0578 (UTC) FILETIME=[BE4B58A0:01C52372]

--_NextPart_5901498AE5B7167A32D274DEED0E3965
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Some content - first line
some content - third line (one is empty)
--_NextPart_5901498AE5B7167A32D274DEED0E3965
Content-Type: application/msword;
	name="invoice.doc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="invoice.doc"
0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAACAAAApwAAAAAAAAAA
...... !!!! not complete attachment since it is irrelevant !!!! .....
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
--_NextPart_5901498AE5B7167A32D274DEED0E3965


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-08 10:43 UTC] derick@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Even if you think it is not a bug, we often know better than you,
please consult the support channels first before even considering
to reopen this report.

Thank you for your interest in PHP.

You\'re abusing the header parameter for email content (body).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC