连接到 Gmail IMAP PHP“无法打开流"

2022-01-23 00:00:00 imap gmail php shell-exec

有很多人有类似的问题,但没有人回答他们的问题.我在 PHP 中启用了 IMAP,使用了所有正确的信息.我看不出哪里出错了.

这是我的代码:

$hostname = '{imap.gmail.com:995/imap/ssl/novalidate-cert}';$username = 'emailaddress@gmail.com';$password = '密码';$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());print_r(imap_errors());

不返回任何错误,除了:

<块引用>

警告:imap_open() [function.imap-open]:无法打开流{imap.gmail.com:995/imap/ssl/novalidate-cert} 在/home/a8066360/public_html/test/imap.php 在第 6 行

无法连接到 Gmail:无法连接到 gmail-imap.l.google.com,995:连接超时

我注意到如果我将单引号更改为 `<块引用>

shell_exec() 出于安全原因已被禁用...

请帮忙!!!

解决方案

你需要993端口,SSL IMAP端口.

端口 995 是 SSL POP3 端口.

There are lots of people having similar issues but no one is answering their questions. I have IMAP enabled in PHP, Using all the correct information. I don't see where I'm going wrong.

Here's my code:

$hostname = '{imap.gmail.com:995/imap/ssl/novalidate-cert}'; 
$username = 'emailaddress@gmail.com'; $password = 'password'; 
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

print_r(imap_errors());

Not returning any errors other than:

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:995/imap/ssl/novalidate-cert} in /home/a8066360/public_html/test/imap.php on line 6

Cannot connect to Gmail: Can't connect to gmail-imap.l.google.com, 995: Connection timed out

I've noticed that if I change the single quotes to `

shell_exec() has been disabled for security reasons...

Please help!!!

解决方案

You need port 993, the SSL IMAP port.

Port 995 is the SSL POP3 port.

相关文章