Get mail from gmail account using php IMAP
P粉930448030
P粉930448030 2024-03-19 20:31:47
0
1
459

I used the php imap function to connect and get the email from the Gmail account and it was working fine, but now, due to their updated policy, I am getting the following error even though the login credentials are correct

PHP Warning: imap_open(): Couldn't open stream {imap.gmail.com:993/ssl/novalidate-cert}[Gmail]/All Mail in

PHP Notice: Unknown: Retrying PLAIN authentication after [AUTHENTICATIONFAILED] Invalid credentials (Failure) (errflg=1) in Unknown on line 0

I think this is because they updated their policy. Is there any way to do this?

These are the current codes connected to the account

$hostname = '{imap.gmail.com:993/ssl/novalidate-cert}[Gmail]/All Mail';
$imap = imap_open($hostname, $username, $password);
$emails = imap_search($imap, 'ALL');
if($emails) echo count($emails);

P粉930448030
P粉930448030

reply all(1)
P粉354948724

Apps that cannot use two-step authentication need to use the application password (instead of the default account password) to log in to Gmail.

For more information about setting an application password in your Gmail account, please visit https://support.google.com/accounts/answer/185833?sjid=6399608693125087466-EU and elsewhere.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template