1
votes

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

1
Have you read what's on the linked webpage? Two-step verification? Less-secure apps? Unlocked Captcha? etc.sebix
Open the website, and read what's there. Also, login using a web browser on the same machine.Max

1 Answers

0
votes

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