I cannot retrieve my mail using imap functions but encounter an error saying 'Couldn't open stream'.
The message is
Warning: imap_open() [function.imap-open]: Couldn't open stream { ... :110 } on line 3
I printed the last error as well in my code,
Cannot connect to Mail: Connection failed to myserver.net,110: Connection timed out
I do not understand 'Connection timed out', because the POP3 server works fine with my mail client such as Outlook.
I followed the directions to retrieve my POP3 mails, and I confirmed through web search that I can use imap functions to retrieve mails in a POP3 server.
I also tried '/novalidate-cert' option and checked the username and password. But there was no difference.
I attached my code below. It is very mysterious for me, can I just connect to the POP3 server?
<?php
$mbox = imap_open("{mail.myserver.net:110/pop3}", "[email protected]", "passme") or die('LAST ERROR: Cannot connect to Mail: ' . imap_last_error());;
echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{mail.myserver.net:110/pop3}", "*");
if ($folders == false) {
echo "Call failed<br />\n";
} else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);
if ($headers == false) {
echo "Call failed<br />\n";
} else {
foreach ($headers as $val) {
echo $val . "<br />\n";
}
}
imap_close($mbox);
?>