title: PHP imap_open() too slow? Any alternatives?
body: <p>Am I doing something wrong with IMAP mail connection? Because just this takes at least 40 seconds:</p>
  
  <pre><code>&lt;?php
      $mbox = imap_open('{myhost.example.com:993/imap/ssl}INBOX', "mymail@example.com", "password");
  
      imap_close($mbox);
  ?&gt;
  </code></pre>
  
  <p>It works, but it's too slow. As you can see - a basic open and close. Okay, 40 seconds might be acceptable, but this is without any operations in between! I tried connecting to gmail IMAP and to my personal host IMAP servers and the results were similar.</p>
  
  <p>Now I tried this:</p>
  
  <pre><code>&lt;?php
      $mbox = imap_open('{myhost.example.com:993/imap/ssl}INBOX', "mymail@example.com", "password");
  
      $unreadMails = imap_search($mbox, 'UNSEEN');
  
      imap_close($mbox);
  ?&gt;
  </code></pre>
  
  <p>By connecting to a freshly created mailbox which has only 3 emails (1 unread) and this took about 80 seconds when I executed it from my PC. I then uploaded this PHP script to my server and tried to execute it there, but it was even slower - it didn't even manage to execute, it timed out. </p>
  
  <p>Am I doing something wrong?</p>