PHP IMAP with Office365 mail
<p>I have searched multiple SO topics on my issue, couldn't find any that would resolve my problem. (One similiar one is here: <a href="https://stackoverflow.com/questions/28481028/access-office356-shared-mailbox-with-php">Access Office356 shared mailbox with PHP</a>)</p>

<p>Currently trying to connect with IMAP PHP to an outlook box, I can succesfully add the IMAP box to my mail client (in mac) and receive the e-mail, though when using PHP I cannot seem to get it working.</p>

<p>My code:</p>

<pre><code>$hostname = '{outlook.office365.com:993/imap/ssl}INBOX';
$username = 'email@example.com';
$password = 'password';

$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
</code></pre>

<p>I have also tried adding novalidate-cert etc. doesn't seem to make any difference</p>

<p>Error's that I am getting:</p>

<pre><code> imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl}INBOX

 [ErrorException]
 imap_open(): Couldn't open stream {outlook.office365.com:993/imap/ssl/novalidate-cert}INBOX
</code></pre>

<p>Hope anyone can get me on the right track.</p>