IMAP:不是有效的imap资源

时间:2014-05-01 10:24:47

标签: php imap

我在PHP中遇到IMAP资源问题:我对以下代码的错误supplied is not a valid imap resource

$imap = imap_open("{"."$host:$port/imap$ssl"."}$folder", $user, $pass);
imap_headers($imap);
$new_emails = imap_search($imap, "UNSEEN");
imap_close($imap);
$counter = $counter+count($new_emails);

我收到以下错误:

warning: imap_close(): supplied is not a valid imap resource on line 896.
warning: imap_headers(): supplied is not a valid imap resource on line 892.
warning: imap_search(): supplied is not a valid imap resource on line 894.

修改

我现在也得到了:

NO IMAP CONNECTION Notice: Undefined variable: imap_connection in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/helpdesk_finance_admin.php on line 214
Warning: imap_getmailboxes(): supplied argument is not a valid imap resource in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/helpdesk_finance_admin.php on line 216
Notice: Undefined variable: imap_connection in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/helpdesk_finance_admin.php on line 220
Warning: imap_headers(): supplied argument is not a valid imap resource in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/helpdesk_finance_admin.php on line 220
Notice: Undefined variable: imap_connection in /var/www/vhosts/talent.co.uk/httpdocs/intranet/model/helpdesk_finance_admin.php on line 222 
Connection failed! Notice: Undefined property: model::$no_mail in /var/www/vhosts/talent.co.uk/httpdocs/intranet/view/helpdesk_finance_admin.php on line 1346
Warning: Invalid argument supplied for foreach() in /var/www/vhosts/talent.co.uk/httpdocs/intranet/view/helpdesk_finance_admin.php on line 1403 

3 个答案:

答案 0 :(得分:0)

最有可能出现错误,imap_open返回FALSE,这不是传递给imap_close的有效资源。

始终检查可能失败的操作结果

答案 1 :(得分:0)

登录详细信息错误,因此imap无法连接,因此会导致错误代码。

答案 2 :(得分:0)

尝试使用此语法 {webmail.talent.co.uk:993/imap/ssl/novalidate-cert}INBOX