#40854 [NEW]: imap_mail_compose() does not work correctly for multiparts e-mails

From: Date: Mon, 19 Mar 2007 14:14:54 +0000
Subject: #40854 [NEW]: imap_mail_compose() does not work correctly for multiparts e-mails
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-110496@lists.php.net to get a copy of this message
From:             mumu at seznam dot cz
Operating system: FreeBSD
PHP version:      5.2.1
PHP Bug Type:     IMAP related
Bug description:  imap_mail_compose() does not work correctly for multiparts e-mails

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

-- 
Edit bug report at http://bugs.php.net/?id=40854&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40854&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40854&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40854&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40854&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=40854&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40854&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40854&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40854&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40854&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40854&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=40854&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=40854&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40854&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40854&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40854&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40854&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40854&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40854&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40854&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40854&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#110496) next »