Error using IMAP in PHP?

断了今生、忘了曾经 提交于 2019-12-24 02:19:06

问题


I was using the code,

<?php
 $mbox = imap_open("https://myserver.in", "developer@myserver.in", "123456", OP_HALFOPEN)
    or die("can't connect: " . imap_last_error());

$list = imap_getmailboxes($mbox, "https://myserver.in", "*");
if (is_array($list)) {
foreach ($list as $key => $val) {
    echo "($key) ";
    echo imap_utf7_decode($val->name) . ",";
    echo "'" . $val->delimiter . "',";
    echo $val->attributes . "<br />\n";
}
} else {
echo "imap_getmailboxes failed: " . imap_last_error() . "\n";
}

imap_close($mbox);
?>

but it is giving the error

Warning: imap_open() [function.imap-open]: Couldn't open stream https://myserver.in in /home/myserver/public_html/vforms/mailtest.php on line 2
 can't connect: Can't open mailbox https://myserver.in: no such mailbox

The error is due to the parameter in imap_open() function, that i am not able to configure. so please help. Is there any PHP Class to fetch data from Inbox, and receive Email messages like PHPMailer Class.


回答1:


Have you had a look at the documentation? The mailbox address needs to be in a very specific format.

// To connect to an SSL IMAP or POP3 server, add /ssl after the protocol
// specification:
$mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id", "password");



回答2:


https != imap

So, probably it's something like

imap_open("{myserver.in:143}INBOX",...

Or:

imap_open("{myserver.in:993/imap/ssl}INBOX",...



回答3:


It could be most likely because of openssl extension since you are reading from the secure protocol that is https. Make sure that you have openssl extension turned on from php.ini.



来源:https://stackoverflow.com/questions/3325150/error-using-imap-in-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!