0

问题是我正在尝试使用 php 从我的电子邮件中获取最后一封电子邮件,并且它在本地运行良好。但后来我将脚本上传到客户端的服务器,但我没有得到响应。当我检查日志时,我得到了这个:

[12-Feb-2020 08:43:21 location] PHP Warning:  imap_open(): Couldn't open stream {<mail>:143/imap}INBOX in /path/triggerCall.php on line 2
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_headers() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 7
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_num_msg() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 14
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_header() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 16
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_fetchbody() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 20
[12-Feb-2020 08:43:21 location] PHP Warning:  imap_close() expects parameter 1 to be resource, boolean given in /path/triggerCall.php on line 40

这是代码:

$inbox = imap_open('{<mail>:143/imap}', '<username>', '<password>');

$headers = imap_headers($inbox);

$last = imap_num_msg($inbox);

$header = imap_header($inbox, $last); 

$body = imap_fetchbody($inbox, $last,1);

我努力了:

{<mail>:993/imap/novalidate-cert}INBOX
{<mail>:995/pop3/tls}INBOX
{<mail>:995/pop3/ssl}INBOX
{<mail>:993/imap/ssl}INBOX
{<mail>:110/pop3}INBOX
{<mail>:993/imap/tls/novalidate-cert}INBOX
{<mail>:143}INBOX

但这些方法都不起作用。有任何想法吗?

4

2 回答 2

-1
$mailbox = {outlook.office365.com:993/imap/ssl}.INBOX;

$this->mbox = imap_open($mailbox,USERNAME, PASSWORD, OP_READONLY) or die("can't connect: " . imap_last_error());
于 2021-02-24T10:39:06.730 回答
-1

尝试这个

$inbox = imap_open('{mail.gmail.com/ssl/novalidate-cert}INBOX', 'email', '密码');

于 2020-02-17T08:41:01.023 回答