Search code examples
phpimap

Accessing ddeboer/Imap Mail Header


I'm accessing a mailbox using ddeboer/imap. Connecting to the Server and retrieving Messages ist not a problem. But $message->getHeaders() returns the following (shortened Version):

Ddeboer\Imap\Message\Headers Object
(
    [storage:ArrayIterator:private] => Array
        (
            [date] => Fri, 5 Jul 2019 07:00:47 +0200
            [subject] => Test Mail
            [message_id] => <[email protected]>

            [fromaddress] => "Test" <[email protected]>
            [from] => Array
                (
                    [0] => stdClass Object
                        (
                            [personal] => Test
                            [mailbox] => test
                            [host] => test.de
                        )

                )

            [deleted] =>  
            [draft] =>  
            [msgno] => 1
            [maildate] =>  5-Jul-2019 07:00:49 +0200
            [size] => 223715
            [udate] => 1562302849
        )

)

How am I supposed to access the Information e.g. udate or from->mailbox?


Solution

  • You can use the get method and add the path

    $message->getHeaders()->get('udate'):
    $message->getHeaders()->get('from')[0]->mailbox