title: PHP IMAP Exchange Issue
body: <p>So I have a little problem with a PHP script I'm currently writing. To start off, let me say the script is supposed to connect to an IMAP mailbox, search for some emails and download their attachments. All of this is already coded and is working with my own gmail account. The problem arise when I try and connect to an exchange server. Short code excerpt : </p>
  
  <pre><code>$mbox = imap_open($host, $login, $password);
  echo '&lt;br/&gt;' . imap_last_error() . '&lt;br/&gt;';
  $emails = imap_search($mbox, 'FROM "patate@patate.com"', SE_UID);
  </code></pre>
  
  <p>I have tried two main $host "version" (with and without SSL) : </p>
  
  <p>1 - {server:993/imap/ssl/novalidate-cert}INBOX
  2 - {server:143/imap/novalidate-cert}INBOX</p>
  
  <p>The novalidate-cert deal with a certificate error. I also tried the "notsl" parameters, for both of these, without any noticeable outcome. The error I get is this lovely message, absolutely not cryptic in any way, shape or form : </p>
  
  <pre><code>[CLOSED] IMAP connection broken (server response)
  </code></pre>
  
  <p>Additionally, I also receive these notices : </p>
  
  <pre><code>Notice: Unknown: Unknown GSSAPI failure: An invalid name was supplied (errflg=1) in Unknown on line 0 
  Notice: Unknown: GSSAPI mechanism status: Hostname cannot be canonicalized (errflg=1) in Unknown on line 0 
  Notice: Unknown: Retrying PLAIN authentication after AUTHENTICATE failed. (errflg=1) in Unknown on line 0 
  Notice: Unknown: Retrying PLAIN authentication after AUTHENTICATE failed. (errflg=1) in Unknown on line 0 
  Notice: Unknown: Can not authenticate to IMAP server: AUTHENTICATE failed. (errflg=2) in Unknown on line 0 
  Notice: Unknown: [CLOSED] IMAP connection broken (server response) (errflg=1) in Unknown on line 0
  </code></pre>
  
  <p>The first two especially puzzle me... I did try this script on another server, to make sure the issue was not related to my local network. After a lot of googling around, I only got this : <a href="http://www.phpfreaks.com/forums/index.php?topic=190628.0" rel="noreferrer">http://www.phpfreaks.com/forums/index.php?topic=190628.0</a> which seems like a somewhat cumbersome fix.</p>
  
  <p>Any ideas?</p>