1

I am trying to access my gmail inbox using imap. I have applied almost all the possible solutions available here and also in google. But i am facing the same issue.

Below is my code :

 $hostname = "{imap.gmail.com:993/imap/ssl/novalidate-cert}";

$mailbox = imap_open($hostname, 'my gmail account', 'my gmail password');

if ($mailbox) 
{
    echo 'if';
} 
else
    {
        echo 'else';
    }
    exit;

When i run this code in to my local system it will give me some message like this :

Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert} in D:\xampp\htdocs\php-imap-mailboxes\test-mail.php on line 4
else
Notice: Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0

Notice: Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0

Notice: Unknown: [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure) (errflg=1) in Unknown on line 0

Notice: Unknown: Too many login failures (errflg=2) in Unknown on line 0

I am running this script in to my local system. Please help me in to this as i have already spent lot's of time in this issue.

Thanks, Ali

Machavity
  • 30,841
  • 27
  • 92
  • 100
aliasgar vanak
  • 664
  • 8
  • 22
  • Have you read what's on the linked webpage? Two-step verification? Less-secure apps? Unlocked Captcha? etc. – sebix Jul 14 '15 at 14:02
  • Open the website, and read what's there. Also, login using a web browser on the same machine. – Max Jul 14 '15 at 14:21

1 Answers1

0

Make sure you have OpenSSL installed.

Here is a related discussion on google groups. https://groups.google.com/forum/#!topic/comp.lang.php/JB5hm8cKi_Q

Michael B
  • 1,660
  • 3
  • 28
  • 59