php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40854 imap_mail_compose() does not work correctly for multiparts e-mails
Submitted: 2007-03-19 14:14 UTC Modified: 2007-03-19 22:57 UTC
From: mumu at seznam dot cz Assigned: iliaa (profile)
Status: Closed Package: IMAP related
PHP Version: 5.2.1 OS: FreeBSD
Private report: No CVE-ID: None
 [2007-03-19 14:14 UTC] mumu at seznam dot cz
Description:
------------
The imap_mail_compose() function does not handle the last part of the body correctly. The MIME header etc. appears twice - once as expected and second (pluse "--" text) after the last boundary.

Reproduce code:
---------------
The same example as on http://cz.php.net/manual/en/function.imap-mail-compose.php

<?php

$envelope["from"]= "joe@example.com";
$envelope["to"]  = "foo@example.com";
$envelope["cc"]  = "bar@example.com";

$part1["type"] = TYPEMULTIPART;
$part1["subtype"] = "mixed";

$filename = "/tmp/imap.c.gz";
$fp = fopen($filename, "r");
$contents = fread($fp, filesize($filename));
fclose($fp);

$part2["type"] = TYPEAPPLICATION;
$part2["encoding"] = ENCBINARY;
$part2["subtype"] = "octet-stream";
$part2["description"] = basename($filename);
$part2["contents.data"] = $contents;

$part3["type"] = TYPETEXT;
$part3["subtype"] = "plain";
$part3["description"] = "description3";
$part3["contents.data"] = "contents.data3\n\n\n\t";

$body[1] = $part1;
$body[2] = $part2;
$body[3] = $part3;


echo nl2br(imap_mail_compose($envelope, $body));
  exit;
?>

Expected result:
----------------
From: joe@example.com
To: foo@example.com
cc: bar@example.com
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="0-1804289383-1174312409=:47393"

--0-1804289383-1174312409=:47393
Content-Type: APPLICATION/octet-stream
Content-Transfer-Encoding: BASE64
Content-Description: imap.c.gz



--0-1804289383-1174312409=:47393
Content-Type: TEXT/plain; CHARSET=US-ASCII
Content-Description: description3

contents.data3



----0-1804289383-1174312409=:47393
Content-Type: TEXT/plain; CHARSET=US-ASCII
Content-Description: description3

--

Actual result:
--------------
Something like:

From: joe@example.com
To: foo@example.com
cc: bar@example.com
MIME-Version: 1.0
Content-Type: MULTIPART/mixed; BOUNDARY="0-1804289383-1174312409=:47393"

--0-1804289383-1174312409=:47393
Content-Type: APPLICATION/octet-stream
Content-Transfer-Encoding: BASE64
Content-Description: imap.c.gz



--0-1804289383-1174312409=:47393
Content-Type: TEXT/plain; CHARSET=US-ASCII
Content-Description: description3

contents.data3



----0-1804289383-1174312409=:47393

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-19 14:48 UTC] mumu at seznam dot cz
I'm sorry, I have switched Expected and Actual Results. This means that what is written as Expected Results is Actual Results and vice versa.
 [2007-03-19 22:57 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 03:01:29 2024 UTC