php-ews icon indicating copy to clipboard operation
php-ews copied to clipboard

getMailbox() with ToRecipients

Open Shaeldon opened this issue 7 years ago • 5 comments

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?

Shaeldon avatar Apr 27 '18 12:04 Shaeldon

Does $mail->getToRecipients()->getMailbox()->getEmailAddress() cause an exception? Also, what does $mail->getToRecipients()->Mailbox->getEmailAddress() even return? the toRecipients should be an array...

Garethp avatar Apr 27 '18 14:04 Garethp

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.

Shaeldon avatar May 03 '18 08:05 Shaeldon

I confirm the words of @Shaeldon.

It would be more convenient if it was an array in all cases.

r-hede avatar Jul 31 '18 12:07 r-hede

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

wleona3 avatar Sep 20 '20 00:09 wleona3

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 ¯\(ツ)

wleona3 avatar Sep 20 '20 00:09 wleona3