imap_open(): Couldn't open stream

I did created web application which has a function to check mail box with imap

and it is working

but the same function fail when called from console application

with error imap_open(): Couldn’t open stream {imap_connect_string}

Anyone with suggestion or experiance on this

This might be WAY too simple but is there something in the you config/main.php file that you have not included in your config/console.php file that is used to make the connection?

Console application is accessing the function

and it is plain php, no additional resources required