Getting Error like imap_open(): Couldn't open

2019-07-09 04:21发布

To fetch gmail mails, i am using below code. it is working fine in local, but i am getting error in server like :

Warning: imap_open(): Couldn't open stream {imap.googlemail.com:993/imap/ssl/novalidate-cert}INBOX in C:\xampp\htdocs\criticaloglive\email_real.php on line 10 Cannot connect to Gmail: Too many login failures

Here's my code :

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$server = '{imap.googlemail.com:993/imap/ssl/novalidate-cert}INBOX'; 
$username = 'mymail@gmail.com';
$password = 'mypassword';

// try to connect 
$inbox = imap_open($server,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());

标签: php gmail imap
1条回答
爷、活的狠高调
2楼-- · 2019-07-09 04:41

Use the $hostname instead of $server. also try with not secure imap with port 143

$inbox = imap_open($hostname,$username,$password) ;

this code works for me.

查看更多
登录 后发表回答