Connecting to Gmail through IMAP with PHP - SSL context failed

前端 未结 10 1872
野的像风
野的像风 2020-12-13 14:37

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

相关标签:
10条回答
  • 2020-12-13 15:32

    Check your setup with phpinfo() and ensure you see --with-imap-ssl listed.

    0 讨论(0)
  • 2020-12-13 15:34

    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.

    0 讨论(0)
  • 2020-12-13 15:35

    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

    0 讨论(0)
  • 2020-12-13 15:35

    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:

    • https://bugs.php.net/bug.php?id=77108
    • https://bugs.launchpad.net/ubuntu/+source/php-imap/+bug/1834340

    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.

    0 讨论(0)
提交回复
热议问题