Haymps
Haymps

Reputation: 91

Cannot read gmail from AWS with PHP

I moved from Netfirms to AWS. This code worked on Netfirms, but I get this error running on AWS:

Can not authenticate to IMAP server: [ALERT] - Can't connect to '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX': 1.

$connect_to = '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX';
$user = '[email protected]';
$password = 'mypassword';

$mbox = imap_open($connect_to, $user, $password) 
    or die("Can't connect to '$connect_to': " . print_r(imap_errors()));

Upvotes: 2

Views: 1965

Answers (1)

Haymps
Haymps

Reputation: 91

This fixes it...

I clicked the link (accounts.google.com/DisplayUnlockCaptcha) from my PC. It replied that my account was unlocked. Then when I tried the program again from AWS instance, it worked and now I can read gmail emails. This had to be locked from the beginning, but I don't know how my other servers (Netfirms and my PC) were able to read, but not AWS. One person guessed, because it was a new IP address that gmail blocked it right out of the gate.

Upvotes: 4

Related Questions