Search code examples
phpobjectimap

Get specific data out of php object


Using https://github.com/ddeboer/imap, in combination with an office365 account, I need to retrieve the email address that sent the email.

To retrieve, I use:

$message->getFrom()

But the result is:

Ddeboer\Imap\Message\EmailAddress Object
(
    [mailbox:Ddeboer\Imap\Message\EmailAddress:private] => my
    [hostname:Ddeboer\Imap\Message\EmailAddress:private] => email.com
    [name:Ddeboer\Imap\Message\EmailAddress:private] => Full Name
    [address:Ddeboer\Imap\Message\EmailAddress:private] => [email protected]
)

How do I retrieve only the last part in this object (I need [email protected])


Solution

  • $message->getFrom()->getAddress()
    

    Source.