title: PEAR/POP3 connects to mailserver, php-imap doesn't
body: <p>We have a php script to handle bounce mails. Now I have to take care of switching from the PEAR NET/POP3 library to the native-ish php-imap library.</p>
  
  <p>The mailserver listens on a remote server on port 110 without ssl (obviously POP3).</p>
  
  <p>However I am unable to open a connection to that server using the php-imap library using the following code:</p>
  
  <pre><code>imap_open("{example.com:110/pop3/notls}INBOX", $username, $password);
  </code></pre>
  
  <p>This results in the following errors:</p>
  
  <pre><code>Warning: imap_open(): Couldn't open stream {example.com:110/pop3/notls}INBOX in C:\xampp\htdocs\bounce-processing\info.php on line 1
  Notice: Unknown: POP3 connection broken in response (errflg=2) in Unknown on line 0
  </code></pre>
  
  <p>The following PEAR POP3 implementation still works:</p>
  
  <pre><code>require("Net/POP3.php");
  $pop3 = new Net_POP3();
  $pop3-&gt;connect('example.com', 110)
  $pop3-&gt;login($username, $password);
  </code></pre>
  
  <p>What I already tried:</p>
  
  <pre><code>imap_open("{IP-ADDRESS:110/pop3/notls}INBOX", $username, $password);
  imap_open("{IP-ADDRESS:110/pop3/notls/user=$username}INBOX", $username, $password);
  </code></pre>
  
  <p>NOTE: I also tested this on different setups (CentOS / Apache 2.2, Ubuntu 14.04 / nginx, PHP 5.4, PHP 5.5, PHP 5.6, no different outcome.</p>
  
  <p>What can I do? Debugging did not really help me - and that the pear class works freaks me out.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT</strong>: php binary is compiled with imap / ssl and the php-imap extension is enabled in the php.ini. If you know another future-proof way to make php talk to a pop3 mailserver, let me know. We don't want to use frameworks such as phpmailer etc.</p>
  
  <p><strong>EDIT2</strong>: telnet login works with a success rate of 40%. I was able to successfully log in 4 out of 10 times with correct credentials.</p>
  
  <p>Output of the CAPA command:</p>
  
  <pre><code>CAPA
  +OK Here's what I can do:
  STLS
  TOP
  USER
  LOGIN-DELAY 10
  PIPELINING
  UIDL
  IMPLEMENTATION Courier Mail Server
  .
  </code></pre>
  
  <p>I don't know if thats important, but the mailserver is in fact hosted by a dedicated server housing and hosting company.</p>
  
  <p><strong>EDIT3:</strong> Trying to connect via</p>
  
  <pre><code>{IP_ADDRESS:110/pop3}
  </code></pre>
  
  <p>returns the following errors:</p>
  
  <pre><code>Warning: imap_open(): Couldn't open stream {IP_ADDRESS:110/pop3} in C:\xampp\htdocs\bounce-processing\index.php on line 12
  Notice: Unknown: Certificate failure for IP_ADDRESS: Server name does not match certificate.
  </code></pre>
  
  <p><strong>Appending the flag novalidate-cert leads to a timeout.</strong></p>