php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24490 imap_headerinfo returns only one address in To field
Submitted: 2003-07-03 18:14 UTC Modified: 2003-07-22 11:45 UTC
From: bob at midnightweb dot net Assigned:
Status: Not a bug Package: IMAP related
PHP Version: 4.3.3RC2-dev OS: RedHat Linux 8.0
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bob at midnightweb dot net
New email:
PHP Version: OS:

 

 [2003-07-03 18:14 UTC] bob at midnightweb dot net
Description:
------------
The imap_headerinfo() function appears to only return the first address in the To field of messages that contain more than one address in that field.  Addresses in the Cc field apear to be unaffected by this bug.

I have tried upgrading the C-Client to 2002b-6, and then recompiling the latest stable PHP release ( 4.3.2 ).

The examples are given with a message with the following To headers:

-- Begin snipit --
From: "Bob" <me@mydomain.com>
To: <user@mydomain.com>, <user2@mydomain.com>,
        <user3@mydomain.com>
--  End snipit  --

NOTE: The email addresses in this report have been altered to preserve the privacy of the user.

Reproduce code:
---------------
$mailbox = imap_open($servername.".$cfldr", $username, $password);
$msgheader = @imap_headerinfo($mailbox, $msg);
ob_start();
print_r( $msgheader );
error_log( ob_get_contents() );
ob_end_clean();

Expected result:
----------------
In the error_log of the web server, there should be a print_r output of the object returned by imap_headerinfo() that looks as follows with the "to" and "toaddress" elements:
-- Begin assumed snipit --
    [toaddress] => "user@mydomain.com" <user@mydomain.com>
    [to] => Array
        (
            [0] => stdClass Object
                (
                    [personal] => user@mydomain.com
                    [mailbox] => user
                    [host] => mydomain.com
                )
            [1] => stdClass Object
                (
                    [personal] => user2@mydomain.com
                    [mailbox] => user2
                    [host] => mydomain.com
                )
            [2] => stdClass Object
                (
                    [personal] => user3@mydomain.com
                    [mailbox] => user3
                    [host] => mydomain.com
                )
        )

--  End assumed snipit  --

Actual result:
--------------
There is the print_r output, however with incomplete "to" array and "toaddress" string elements:
-- Begin snipit --
    [toaddress] => "user@mydomain.com" <user@mydomain.com>
    [to] => Array
        (
            [0] => stdClass Object
                (
                    [personal] => user@mydomain.com
                    [mailbox] => user
                    [host] => mydomain.com
                )

        )
--  End snipit  --


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-04 05:21 UTC] bob at midnightweb dot net
I installed the reccommended CVS snapshot, and the To field is still only populating one address.
 [2003-07-21 14:00 UTC] vlad@php.net
Just checked this with the latest CVS and imap-2002d (they don't have 2002b-6 there anymore). Everything works as expected (see output below). Could you compile PHP against a newer IMAP lib, e.g. 2002d?

---------------------------------------
[vlad@palana src]$ ./imap_test.php
Content-type: text/html
X-Powered-By: PHP/4.3.3RC2-dev

object(stdClass)(23) {
  ["date"]=>
  string(31) "Mon, 21 Jul 2003 11:53:47 -0700"
  ["Date"]=>
  string(31) "Mon, 21 Jul 2003 11:53:47 -0700"
  ["subject"]=>
  string(5) "test3"
  ["Subject"]=>
  string(5) "test3"
  ["message_id"]=>
  string(30) "<3F1C36BB.20700@echospace.com>"
  ["toaddress"]=>
  string(96) ""vlad@echospace.com" <vlad@echospace.com>, "vkegeneric@echospace.com" <vkegeneric@echospace.com>"
  ["to"]=>
  array(2) {
    [0]=>
    object(stdClass)(3) {
      ["personal"]=>
      string(18) "vlad@echospace.com"
      ["mailbox"]=>
      string(4) "vlad"
      ["host"]=>
      string(13) "echospace.com"
    }
    [1]=>
    object(stdClass)(3) {
      ["personal"]=>
      string(24) "vkegeneric@echospace.com"
      ["mailbox"]=>
      string(10) "vkegeneric"
      ["host"]=>
      string(13) "echospace.com"
    }
  }
...
 [2003-07-21 17:56 UTC] bob at midnightweb dot net
Well, I upgraded my c-client again, and installed the latest PHP4 Stable CVS, and it still wouldn't work.  I created a small test script with the following code:
<?
        header( "Content-Type: text/plain" );
        $mailbox = imap_open( "{myserver:143}INBOX", "username", "password" );
        print "$msg\n";
        $headers = imap_headerinfo( $mailbox, 11 );
        print "toaddress  =  ".$headers->toaddress."\n";
        print "to         =  ";
        print_r ( $headers->to );
        imap_close($mailbox);
?>
And the output was correct!  However, my othercode still did not work, and I gather it is because the imap_headerinfo() function is within a fucntion, so it apears that I have unearthed another bug...
The function that it is in only takes two arguments: the message number, and the resource stream.  In order for the imap_headerinfo() function to work properly, I had to do the following:

$check = imap_mailboxmsginfo($mailbox);
imap_reopen( $mailbox, $check->Mailbox );

I think its kinda funky that this has to be done to work properly.
 [2003-07-22 11:45 UTC] vlad@php.net
Therefore, this is not a bug. I am not sure what you mean by "unearthing another bug". If you want me to look into it, email me, but this bug is now closed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 15:01:36 2024 UTC