Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Office 365 - Array to string conversion error #131

Closed
jasonsyko opened this issue Aug 4, 2016 · 1 comment
Closed

Office 365 - Array to string conversion error #131

jasonsyko opened this issue Aug 4, 2016 · 1 comment

Comments

@jasonsyko
Copy link

When iterating through messages, I want to get the address the email was sent to. However, the object $message->getTo() gives an array to string conversion error.

See code below.

`function get_emails(){

    $server = new Server('outlook.office365.com');
    $connection = $server->authenticate('email', 'password');

    $mailbox = $connection->getMailbox('INBOX');

    $messages = $mailbox->getMessages();

    //var_dump($messages);

    foreach ($messages as $message){
        if($message->isSeen() !=1){
            echo "<p>".$message->getSubject()."</p>";
            echo "<p>".$message->getTo()."</p>";
        }
    }
}`

Error: Notice: Array to string conversion in /path/to/file/ on line 58

Any fix for this?

@jasonsyko
Copy link
Author

Ahh simple solution - implode the array to convert it to a string. Problem solved.

echo implode($message->getTo());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant