ddeboer / imap

Object-oriented, fully tested PHP IMAP library
MIT License
885 stars 253 forks source link

Problem with GMAIL #461

Open phpiando opened 4 years ago

phpiando commented 4 years ago

Hello guys, I need some help. I'm having trouble connecting to a Gmail account, I've already made all the possible settings I found on the internet, including enabling imap on the account, enabling less secure apps, disabling any irregular activity, but none of this is working, I'm having the same feedback : https://prnt.sc/sfuyuz

The php version is 7.2, all libs are active, imap, openssl, and others that I verified are necessary, and as said, nothing makes the account connect.

I have also tried to change to connect without SSL, but without success.

Below is the excerpt from my code.

try {
            foreach ($mailboxes as $key => $mailbox) {
                $hostname = 'custom' == $mailbox['server'] ? $mailbox['imap'] : $mailbox['server'];
                $cert = 143 == $mailbox['port'] ? '/imap/novalidate-cert' : '/imap/ssl/validate-cert';

                $server = new Server($hostname, $mailbox['port'], $cert);
                $connection = $server->authenticate($mailbox['email'], $mailbox['password']);

                $this->readMailboxes($connection, $mailbox);
            }
        } catch (Exception $e) {
            throw new Exception($e->getMessage(), 1);
        }
piernik commented 4 years ago

Try to add flag /imap/ssl/novalidate-cert

arnolem commented 3 years ago

Hello, You need to create a specific password for your application. https://support.google.com/accounts/answer/185833