|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49529 imap_mail_compose changes passed parameters
Submitted: 2009-09-11 11:24 UTC Modified: 2009-09-19 01:00 UTC
From: hrynek at hrynek dot com Assigned:
Status: No Feedback Package: IMAP related
PHP Version: 5.2.10 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: hrynek at hrynek dot com
New email:
PHP Version: OS:


 [2009-09-11 11:24 UTC] hrynek at hrynek dot com
imap_mail_compose() corrupts passed $envelope parameter, even passed 
indirectly - check $headers and $this->headers used in sample code.

All address headers (from, to, cc, bcc, reply_to etc.) are changed and 
variable can't be passed to imap_mail_compose() next time, beacause 
function produces notice and wrong mail headers:

Any modification (uncomment line in sample) to variable 
prevents changes to $this->headers, but $headers is still being 

Reproduce code:
class test {
    protected $headers = array("from" => "Asdf Qwer <asdf@qwer.invalid>");
    protected $body = array(array(
        "type" => TYPETEXT,
        "subtype" => "plain",
        "" => "test message",
    protected function getHeaders() {
        return $this->headers;
    public function compose() {
        $headers = $this->getHeaders();
        //$headers["from"] .= ""; // uncomment to fix
        imap_mail_compose($headers, $this->body);
$test = new test();

Expected result:
string(29) "Asdf Qwer <asdf@qwer.invalid>"
string(29) "Asdf Qwer <asdf@qwer.invalid>"

Actual result:
string(29) "Asdf Qwer <asdf@qwer.invalid>"
string(29) "Asdf Qwer<asdf@qwer.invalid>"

One space is replaced by 0x00.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-11 13:33 UTC]
Please try using this snapshot:
For Windows:

I can not reproduce this using your example script.
 [2009-09-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Mar 03 15:01:24 2021 UTC