【发布时间】:2020-01-26 10:41:52
【问题描述】:
我正在尝试使用此代码从 gmail 收件箱中检索现有电子邮件:
'<?php
$yourEmail = "blablabla@gmail.com";
$yourEmailPassword = "xxxxxxxx";
$mailbox = imap_open("{imap.gmail.com:993/ssl}INBOX", $yourEmail, $yourEmailPassword);
$mail = imap_search($mailbox, "ALL");
$mail_headers = imap_headerinfo($mailbox, $mail[0]);
$subject = $mail_headers->subject;
$from = $mail_headers->fromaddress;
imap_setflag_full($mailbox, $mail[0], "\\Seen \\Flagged");
imap_close($mailbox);
?>'
我找不到任何解释如何做的教程。 我还尝试更改差异端口以建立至少一个连接,但没有任何努力。
我给出的错误如下:
PHP Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/ssl}INBOX in G:\\xampp\\htdocs\\otika-bootstrap-admin-template\\imap.php on line 6, referer: http://localhost/otika-bootstrap-admin-template/
PHP Warning: imap_search() expects parameter 1 to be resource, bool given in G:\\xampp\\htdocs\\otika-bootstrap-admin-template\\imap.php on line 7, referer: http://localhost/otika-bootstrap-admin-template/
PHP Warning: imap_headerinfo() expects parameter 1 to be resource, bool given in G:\\xampp\\htdocs\\otika-bootstrap-admin-template\\imap.php on line 8, referer: http://localhost/otika-bootstrap-admin-template/
PHP Notice: Trying to get property 'subject' of non-object in G:\\xampp\\htdocs\\otika-bootstrap-admin-template\\imap.php on line 9, referer: http://localhost/otika-bootstrap-admin-template/
PHP Notice: Trying to get property 'fromaddress' of non-object in G:\\xampp\\htdocs\\otika-bootstrap-admin-template\\imap.php on line 10, referer: http://localhost/otika-bootstrap-admin-template/
PHP Warning: imap_setflag_full() expects parameter 1 to be resource, bool given in G:\\xampp\\htdocs\\otika-bootstrap-admin-template\\imap.php on line 11, referer: http://localhost/otika-bootstrap-admin-template/
PHP Warning: imap_close() expects parameter 1 to be resource, bool given in G:\\xampp\\htdocs\\otika-bootstrap-admin-template\\imap.php on line 12, referer: http://localhost/otika-bootstrap-admin-template/
PHP Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0, referer: http://localhost/otika-bootstrap-admin-template/
PHP Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0, referer: http://localhost/otika-bootstrap-admin-template/
PHP Notice: Unknown: [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0, referer: http://localhost/otika-bootstrap-admin-template/
PHP Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0, referer: http://localhost/otika-bootstrap-admin-template/
在这个领域有 exp 的人可以告诉我如何重新编译 php 以包含 --with-imap_sll,因为我认为这可能是问题所在?
我也启用了
imap
在 gmail 上。 我尝试了所有与
相关的主题
imap
过去 2 天内在 stackoverflow 或其他任何地方。
感谢阅读。
【问题讨论】: