Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to receive email on Google Compute Engine

Google's compute engine blocks all outgoing email ports by default. Quote from Compute Engine Documentation

Compute Engine blocks or restricts traffic through all of the following ports/protocols between the Internet and virtual machines, and between two virtual machines when traffic is addressed to their external IP addresses through these ports (this also includes load-balanced addresses): > All outgoing traffic to port 25 (SMTP) is blocked. Most outgoing traffic to port 465 or 587 (SMTP over SSL) is blocked, except for known Google IP addresses.

As a solution to this, Google advices the use of third-party sites like SendGrid to manage email. SendGrid can easily help you send email, but receiving emails is not so easy.

Installing an email client on the server won't help because the ports through which these clients need to communicate with other servers to receive emails remain blocked.

My question is what's the easiest solution to receiving email? SendGrid's solution is for sending emails, and the Compute Engine Documentation specifies this. I've installed postfix but all emails to my server receive timeout errors, and my inbox remains empty.

like image 835
Cedric Ipkiss Avatar asked Jun 25 '17 18:06

Cedric Ipkiss


People also ask

What email does Google App Engine use?

The mail API provides two ways to send an email message: the mail. send_mail() function and the EmailMessage class. This page describes how to use the legacy bundled services and APIs. This API can only run in first-generation runtimes in the App Engine standard environment.

How do I send an email from GCP?

In the Google Cloud console, go to the Create a firewall rule page. Choose a name for the firewall rule. Under Network, select the network that is hosting the VM instance that you intend to send email messages from. Under Direction of traffic, select Egress.


1 Answers

TL;DR - You're right outgoing email ports are blocked, but incoming email ports are not. If you open them, and run a mail server which listens for incoming emails - you can still receive them. You will need to use 3rd party email sender gateways like SendGrid only to send the emails.

Longer version

All outgoing traffic to port 25/465/587 are blocked so that people do not abuse GCE for sending out spam, phishing, etc. emails.

You can still run a mail server which just receives emails. In other words, there is no mention that incoming traffic to those ports are blocked. By default GCE firewall blocks all incoming traffic. You will have to open up these listening ports using firewall rules.

like image 93
Tuxdude Avatar answered Oct 04 '22 07:10

Tuxdude