title: PHP Imap Certificate failure
body: <p>I was pulling my inboxes using <a href="https://packagist.org/packages/php-imap/php-imap" rel="nofollow noreferrer">php-imap/php-imap</a> library and inboxes managed by CPanel. All in sudden script stopped with following error.</p>
  
  <pre><code>Connection error: Certificate failure for imap.domain.com: 
  Server name does not match certificate: 
  /OU=Domain Control Validated/OU=PositiveSSL/CN=&lt;amazon.domain.com&gt;
  </code></pre>
  
  <p>in /.../vendor/php-imap/php-imap/src/PhpImap/Mailbox.php</p>
  
  <p>here is the imap path I am using:
      <code>{imap.domain.com:143/imap/tls}INBOX</code></p>
  
  <p>I also tried <code>{imap.domain.com:143/novalidate-cert/imap/tls}INBOX</code> but all in vain.</p>
  
  <p><strong>What change could have have stopped it?</strong><br>
  <strong>How to fix it and avoid such failure in future?</strong></p>