php-ews
php-ews copied to clipboard
getMailbox() with ToRecipients
To get the sender email adress I use the following Code:
$mail->getSender()->getMailbox()->getEmailAddress()
If i want to get the toRecipient adress I have to use:
$mail->getToRecipients()->Mailbox->getEmailAddress()
Why? Possible bug or by design?
Does $mail->getToRecipients()->getMailbox()->getEmailAddress() cause an exception? Also, what does $mail->getToRecipients()->Mailbox->getEmailAddress() even return? the toRecipients should be an array...
1.) $mail->getToRecipients()->getMailbox()->getEmailAddress() throws Error: Call to undefined method stdClass::getMailbox()
2) Returns if only one ToRecipient is present a string. If multiple are present an array.
I confirm the words of @Shaeldon.
It would be more convenient if it was an array in all cases.
I can confirm that 2 years later, and on version 0.9.9 this is still an issue. Also the type hint for the return is wrong, so I assume that
the getToRecipients() method should actually be returning MailboxType|MailboxType[], though I don't actually see that class. If this is indeed the case, I don't mind investigating some more and opening a PR
I confirm the words of @Shaeldon.
It would be more convenient if it was an array in all cases.
Yes it would, but unfortunately we're dealing with XML here and that's just the way that it works ¯\(ツ)/¯