title: PHP imap_open() => [AUTHENTICATIONFAILED]
body: <p>I'm trying to set up an IMAP connection to a mail server, the problem is it fails with message:</p>
  
  <pre><code>array(4) {
    [0]=&gt; string(81) "Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Authentication failed."
    [1]=&gt; string(81) "Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Authentication failed."
    [2]=&gt; string(82) "Can not authenticate to IMAP server: [AUTHENTICATIONFAILED] Authentication failed."
    [3]=&gt; string(49) "[CLOSED] IMAP connection broken (server response)"
  }
  </code></pre>
  
  <p>The code that I use to open the connection is:</p>
  
  <pre><code>$mbox = imap_open('{server.test.com:993/imap/ssl}INBOX', 'user@test.com', 'password');
  </code></pre>
  
  <p>I have tested the same syntax for my Gmail account and it works fine. I can connect to the <code>server.test.com</code> and also authenticate using thunderbird (IMAP - SSL - 993), so it's not really the mail server having a problem.</p>
  
  <p>I've searched through Stack Overflow for this issue, but I haven't managed to solve it, below are all the solutions I have tried so far:</p>
  
  <ol>
  <li><code>$mbox = imap_open('{server.test.com:993/imap/ssl}INBOX', 'user@test.com', 'password', null, 1, array('DISABLE_AUTHENTICATOR' =&gt; 'PLAIN'));</code></li>
  <li><code>$mbox = imap_open('{server.test.com:995/pop3/ssl}INBOX', 'user@test.com', 'password');</code></li>
  <li><code>$mbox = imap_open('{server.test.com:993/imap/ssl/novalidate-cert}INBOX', 'user@test.com', 'password'); (The cert is valid)</code></li>
  <li><code>$mbox = imap_open('{server.test.com:993/pop3/ssl/novalidate-cert}INBOX', 'user@test.com', 'password'); (The cert is valid)</code></li>
  <li><code>$mbox = imap_open('{server.test.com:993/imap}INBOX', 'user@test.com', 'password');</code></li>
  <li><code>$mbox = imap_open('{server.test.com:993/pop3}INBOX', 'user@test.com', 'password');</code></li>
  <li><code>$mbox = imap_open('{server.test.com:993}INBOX', 'user@test.com', 'password');</code></li>
  </ol>
  
  <p>Any idea from where the problem can come from? I'll also post all the error messages I got for all the solutions mentioned above and also the mail server and php logs later.</p>
  
  <p>Note: To represent the errors I'm using:</p>
  
  <pre><code>var_dump(imap_errors());
  </code></pre>