Cannot connect to imap Gmail / php imap
<p>While trying to use php's imap functions I can't connect to Gmail's imap server.
I'm using:</p>

<pre><code>$mail = imap_open('{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX', '******@gmail.com', '******') or die('Cannot connect to Gmail: ' . imap_last_error());
</code></pre>

<p>Which returns this message:</p>

<p>Couldn't open stream {imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX in /blabla/mail-handler.php on line 18
Cannot connect to Gmail: Can not authenticate to IMAP server: [ALERT] Please log in via your web browser: <a href="https://support.google.com/mail/acco" rel="nofollow">https://support.google.com/mail/acco</a>
(which seems to cut off).</p>

<p>I've also tried:</p>

<pre><code>imap.gmail.com:993/imap/ssl
</code></pre>

<p>Also tried to connect via server with/without ssl certificate.
Can someone tell what I'm missing here?</p>

<p>According to phpinfo() imap is available.
Also, the less secure apps setting is on (as is imap) in Gmail's settings</p>