#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    1
    Rep Power
    0

    Question Getting addresses of emails using Imap


    Hi all,

    Does anyone knows how I could get all the addresses of an email using PHP imap?

    I followed the example given in the usual PHP website. At the end of the page, you can see the following example:
    PHP Code:
    $header imap_header($mbox$message_id);
    $from $header->from;
    foreach (
    $from as $id => $object) {
        
    $fromname $object->personal;
        
    $fromaddress $object->mailbox "@" $object->host;

    I've change the $header->from with a $header->to to get the "To" addresses. Apparently, the imap_header function retrieves an array of address objects. So this code loops over the address objects to get all the addresses, fine.

    The problem is that the $header->to property returns only one address object, even with email containing several "To" addresses (that I can check using a webmail interface).

    Do you know how I could get the actual array of addresses?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2003
    Posts
    3,508
    Rep Power
    594
    The object should be an array of 'to' addresses just like 'from'. I suggest you do the following to see what is really there:
    PHP Code:
    echo "<pre>";
    var_dump($header->to);
    echo 
    "</pre>"
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo