I\'m trying to connect to Gmail through IMAP with PHP running in Apache. This is on an Ubuntu 9.04 system. I\'ve got some sort of PHP configuration issue that is keeping t
Check your setup with phpinfo()
and ensure you see --with-imap-ssl
listed.
If you're still having issues with this on gmail, make sure to enable "Allow access for less secure apps" in your google accounts security settings page.
One more additional thing you need enabled in PHP, is the OpenSSL extension. It appears that the IMAP Client library (with SSL) depends on this.
It doesn't matter if Apache has the OpenSSL module enabled as this is processed/handled before the request is handed off to PHP.
The following discussion thread may help shed some light:
http://groups.google.com/group/comp.lang.php/browse_thread/thread/241e619bc70a8bf4/bd3ae0c6a82409bc?lnk=raot&pli=1
Specific to Gmail's IMAP servers:
Google has started returning invalid certificates for TLSv13 connections which do not provide SNI hostname. This causes a regression when building php-imap extension against an upgraded OpenSSL (libssl) version. The issues have already been reported here:
The later is quite recent, and I've filed it to Ubuntu maintainers to make it visible to them and hopefully attract more eyes, since it affects Ubuntu Bionic which is a LTS version.
Please, vote and/or comment on them to give better visibility. Also remember: if you this answer useful and it is also upvoted enough, the above issues will get still more visibility.
In the meantime, looks like to me that the only workaround until the bug is fixed is to disable certificate validation by using the /novalidate-cert
flag when calling imap_open(), which is a security risk.