bhavika bhavika - 3 months ago 20
PHP Question

Getting error while fetching emails via imap

i have problem in IMAP
i am writing below code to fetch inbox emails

$hostname = '{mail.test.in:110}INBOX';
$username='name';
$password='password';
$inbox = imap_open($hostname, $username, $password) or die('Cannot connect to Gmail: ' . imap_last_error());


i am getting error

"message": "imap_open(): Couldn't open stream {mail.innovify.in:110}INBOX"


please let me know solution

Answer

According to the imap_open() documentation you need to provide a service flag if you are not using IMAP.

You are using port 110 which is for POP3, so you need to let imap_open() know about that by changing your connection string from

$hostname = '{mail.innovify.in:110}INBOX';

to

$hostname = '{mail.innovify.in:110/pop3}INBOX';

Comments