gyaani_guy
gyaani_guy

Reputation: 3209

Not able to connect using imap_open ()

I am trying to connect and fetch messages of my hosting's email address using imap_open(), but its throwing errors.

$server = '{mail.booksnearby.in:143/imap/ssl/novalidate-cert}INBOX';
$imap_connection = imap_open($server, $login, $password);
$mailboxinfo = imap_mailboxmsginfo($imap_connection);
$messageCount = $mailboxinfo->Nmsgs;

The above throws this error: Array ( [0] => Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Authentication failed.

If I change $server to

$server = '{mail.booksnearby.in:143}INBOX';   

then it throws the following error

Certificate failure for mail.booksnearby.in: self signed certificate:

If $server is

$server = '{mail.booksnearby.in:143/imap/ssl/novalidate-cert}INBOX'; 

it throws

Array ( [0] => TLS/SSL failure for mail.booksnearby.in: SSL negotiation failed )

I can connect to the email account using an email client, with the same username password.

I can't seem to telnet in as well. Its running apache , cpanel and dovecat. Imap with Ssl support is enabled on my hosting..

Upvotes: 8

Views: 16210

Answers (2)

CROSP
CROSP

Reputation: 4617

A bit late, but is still relevant:)

Usually, when the port 143 is used there is no SSL encryption involved. So you don't need to set ssl in your connection string. As a result, it should look like:

$server = '{mail.booksnearby.in:143/imap}INBOX'; 

Hope this will help.

Upvotes: 2

sparkle
sparkle

Reputation: 233

Are you sure that the port number is 143 (not 993)? Cause you are using a secure connection with self signed certificate as I see. Try to do that this way:

$server = '{mail.booksnearby.in:993/imap/ssl/novalidate-cert}INBOX';

Upvotes: 16

Related Questions