Raul
Raul

Reputation: 1

imap_open(): Couldn't open stream in Yii controller

I have really strange issue with imap_open function that it connects to some servers but fails with some servers. in the Yii controller I have

$inbox = imap_open("{".$model->incoming_hostname .":" .$model->incoming_port 
."/ssl/novalidate-cert}",$model->e_mail_username,$model->e_mail_password);

Now when I submit parameters to connect to Gmail account I get the imap_open("{imap.gmail.com:993/ssl/novalidate-cert}", "username", "password") and the inbox is opened fine, the same seems to work for yahoo. But for some reason I get error when connecting to outlook.com or icloud.com e-mail.

imap_open("{imap-mail.outlook.com:993/ssl/novalidate-cert}", "username", "password") gets error imap_open(): Couldn't open stream

What is really strange is that when I run the separate php script I made manually in shell for testing with the same parameters for connecting to outlook.com e-mail account it works fine. Also when I access this script through apache via web browser it also works. So this is not the problem of apache executing php code. But why does it fail in the Yii?

$hostname = '{imap-mail.outlook.com:993/ssl/novalidate-cert}';
$username = 'username';
$password = 'password';

/* try to connect */
$inbox = imap_open($hostname,$username,$password); 

Any suggestions how to track this issue? In Yii I cannot see what could be the problem by calling imap_last_error() because Yii immediately displays error page for the warning

PHP warning

imap_open(): Couldn't open stream {:993/ssl/novalidate-cert}

/var/www/..../controllers/RegisterController.php(102)

Upvotes: 0

Views: 1549

Answers (1)

Babu
Babu

Reputation: 605

try this as hostname

$hostname='{imap-mail.outlook.com:993/imap/ssl}INBOX';

and also you pre check your username

Upvotes: 0

Related Questions