Sending Emails with GCE

3,097 views
Skip to first unread message

Vitul Goyal

unread,
Oct 17, 2015, 3:30:48 AM10/17/15
to gce-discussion
Hi

I have a website hosted on Google Compute Engine. I want to send welcome email to a person who registers on  my website.

I have my domain emails on Gmail for Work.

I tried using SendGrid and MailGun but i am unable to send email. I am using PHP.

Can i use smtp.gmail.com to send emails because all my business emails are already with Gmail? I tried using postfix but nothing was sent. 

I get "SMTP connect() failed" all the time.

Kamran (Google Cloud Support)

unread,
Oct 17, 2015, 1:17:26 PM10/17/15
to gce-discussion

Hello Vitul,

As mentioned in this article, in general Google Compute Engine does not allow outbound connections on ports 25, 465, and 587 but you can still set up your instance to send mail using partner services like SendGrid, Mailgun, or using Google Apps.

However, you should be able to use Gmail SMTP server (smtp.gmail.com) or Google Apps SMTP relay (smtp-relay.gmail.com) from your GCE VMs. This SMTP servers listen on ports 465 and 587 and connecting to them requires enabling and using SSL/TLS protocols.

The other option is using Gmail API which is a RESTful API and can be used to access Gmail mailboxes to send mail.

I hope this information helps.

Sincerely,

Kamran 

Vitul Goyal

unread,
Oct 19, 2015, 4:50:02 AM10/19/15
to gce-discussion
Thanks Kamran for the help.

I tried to setup SendGrid but it was not working. I searched online and found that i had to uninstall sendmail.

After uninstalling SendGrid started working!! :)

Mike L

unread,
Jan 22, 2018, 3:07:09 PM1/22/18
to gce-discussion
Hello,

I wanted to pick up on this thread because currently I am having an issue with setting up SMTP sending from a GCE instance.

While I was able to successfully use port 2525 for Mandrill SMTP sending, adding the custom firewall rule, unfortunately this is for non-encrypted / non-TLS traffic. From what I can find it appears Mandrill only supports TLS/SSL on port 587. So does this mean that for instances on GCE (which blocks port 587 outright) there is no option for us to use TLS connections on port 587 via Mandrill?

Thank you,

-Mike

Mike L

unread,
Jan 22, 2018, 5:49:56 PM1/22/18
to gce-discussion
Turns out I was misinformed on my last post and after a little extra googling + reviewing some configs I discovered the solution. The issue at hand was a configuration restriction on the web application I'm using.

Port 2525 for Mandrill DOES support TLS connections, not only port 587. And in my web application it was coded specifically to check for the web application's email port setting value being "587" in order to use TLS. So I added in a check for port 2525 as well to solve the issue.

Many thanks.
Reply all
Reply to author
Forward
0 new messages