Search code examples
phpemailimap

PHP - IMAP connection to Gmail returns nothing


I am trying to connect to gmail using IMAP. When I try to load the script, the page just loads and and doesn't return anything. No error, no emails... it just tries loading.

I have IMAP enabled for PHP, and it's also enabled in my Gmail inbox.

    $hostname = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
    $username = '[email protected]';
    $password = 'password';
    $inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
    imap_close($inbox);

Any ideas why the script won't stop loading?


Solution

  • Firewall was blocking the port 993. Got it working. Thanks!