title: Fetch Office365 email from the email server in PHP
body: <p>I am unable to fetch the emails from Office 365 mailbox using IMAP.</p>
  
  <p>This used to work perfectly fine when we used to fetch the same from Gmail while now it is getting the following error:</p>
  
  <p>Can't connect to 'hostname',port_number.</p>
  
  <p>I got hostname by following this link => <a href="https://support.knowbe4.com/hc/en-us/articles/115006834408-How-To-Find-Your-Office-365-Host-Name" rel="nofollow noreferrer">https://support.knowbe4.com/hc/en-us/articles/115006834408-How-To-Find-Your-Office-365-Host-Name</a></p>