Google SMTP Connection Timeout

Sending email from an EC2 instance is just not a good idea unless you are handing the email to a mail server that has specifically agreed to accept your mail. There are a variety of reasons, but the main one is that an EC2's IP address is dynamic and a mail server must be on a static IP address to accept bounces.

Basically, if you want to send mail, you need to send it to a real mail server that will take responsibility for delivering the mail to its destination. Amazon offers such services, with real mail servers hosted at static IP addresses.


Most of the times that I see similar problems with mail servers (and from the logs presented I understand that you connect to ALT1.aspmx.l.google.com but mail is not sent) disabling TCP Window scaling helps bypassing (not solving) the problem.

I do not know what OS you're running on the EC2, but if it is Linux you may try adding:

net.ipv4.tcp_rmem = 4096 87380 174760
net.ipv4.tcp_wmem = 4096 16384 131072
net.ipv4.tcp_window_scaling = 0

in your /etc/sysctl.conf and run sysctl -p afterwards.


I've found Google has locked accounts/IP Addresses/ActiveSync etc when their automated protection systems suspect suspicious activity.

ie, A user using Outlook with POP/SMTP suddenly can't log in with Outlook.

To 'unlock' an IP, you can log into the GMail account from that IP using the website gmail.com, and the account will usually come good in a few minutes.

Otherwise Google Tech Support once directed me to https://www.google.com/accounts/UnlockCaptcha or http://www.google.com/a/your_domain.com/UnlockCaptcha for an account that ActiveSync had locked down and nothing would bring it back.

See here for more information: http://www.gmailhelp.com/2009/10/unlocking-googles-gmail-captcha/