PHP imap,无法连接

I get the following response when attempting to connect to imap server, using tls and self-sighned certificate.

Connection error: [CLOSED] IMAP connection broken (server response)

the Imap open is the following

$mailbox = new ImapMailbox('{mail.NNNNNN.com:143}', 'YYY@NNNN.com', 'IIIII');

I can't really understand from where this error is coming from , if though i installed locally the server certificate it still fails.

i added {mail.NNNNN.com:143}/INBOX but it still doesnt seem it can connect.


edited

after setting up stunnel it logs the following information

  • 2015.11.09 16:02:14 LOG5[2]: Service [imapsrv] accepted connection from 127.0.0.1:8848
  • 2015.11.09 16:02:14 LOG5[2]: s_connect: connected NNN.NN.NN.NN:143
  • 2015.11.09 16:02:14 LOG5[2]: Service [imapsrv] connected remote server from 192.168.1.73:8849
  • 2015.11.09 16:02:14 LOG3[2]: SSL_connect: 1408F10B: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
  • 2015.11.09 16:02:14 LOG5[2]: Connection reset: 0 byte(s) sent to SSL, 0 byte(s) sent to socket