title: Can't connect to Office 365 using php imap_open
body: <p>I am trying to connect to Office 365 using PHP Imap but it won't connect with Office 365.  Everything works fine for gmail and other email hosts but on Office 365 I get a can not authenticate (I am sure the email and password are correct).</p>
  
  <p>Server has an SSL certificate and IP Address has been whitelisted in Office.  I am thinking it is something to do with the hostname.</p>
  
  <p>This is what I am currently trying:</p>
  
  <pre><code>{outlook.office365.com:993/imap/ssl}
  </code></pre>
  
  <p>Also tried:</p>
  
  <pre><code>{outlook.office365.com:993/imap/ssl/novalidate-cert}
  </code></pre>
  
  <p>And </p>
  
  <pre><code>{outlook.office365.com:993/ssl}
  </code></pre>
  
  <p><strong>UPDATE</strong>
  It looks like this may be because this is a shared account based on the screenshot.  Would this change my hostname?</p>
  
  <p><a href="https://i.stack.imgur.com/I56ob.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I56ob.png" alt="enter image description here"></a></p>