3

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());
vvns
  • 3,548
  • 3
  • 41
  • 57
Ramya
  • 151
  • 1
  • 4
  • 6

1 Answers1

2

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.

Riad
  • 3,822
  • 5
  • 28
  • 39