Google Compute Engine does not allow outbound connections on ports 25, 465, and 587 but you can still set up your instances to send mail through ports 587, 465, and 2525 using servers provided through partner services.
For example, you can send email through port 2525 using Compute Engine's third-party partner, SendGrid. To send email through ports 587 or 465, you can use your Google Apps domain if you have one. Additionally, you can send email on any of the ports not blocked by Compute Engine. This document compares some of the options you have for sending mail and provides general recommendations.
Keep in mind that while sending email from blocked ports is not allowed, your instances can still receive email.
Why are standard email ports blocked?
By default, standard outbound SMTP ports are blocked because of the large amount of abuse these ports are susceptible to. In addition, having a trusted third-party provider such as SendGrid relieves Compute Engine or you from having to maintain IP reputation with your receivers. You can use other email providers like SendGrid, or if you have a Google Apps domain, Google Apps, to maintain this reputation for you.
Using SendGrid, a Google Apps account, or a custom port
SendGrid is Compute Engine's third-party partner that provides a free tier for Compute Engine customers to set up and send email through SendGrid's servers. If you don't have a Google Apps account, we suggest using SendGrid which offers click tracking, analytics, an API, and other features that can meet your email needs.
On the other hand, if you are familiar with Google Apps and are already paying for a Google Apps account that supports email, you can set up a relay service to send email through Google Apps. Note that Gmail and Google Apps enforce limits for email activity. For details, see Google Apps email sending limits.
It is also possible to set up an email server on your instance using a non-standard port. Some services choose to do this on port 2525, but you can choose any ephemeral port that isn't blocked by Compute Engine.
Set up email services from an instance
- To use SendGrid for sending email, follow the instructions for Sending Email using SendGrid.
- To use a Google Apps domain, follow the instructions for SMTP relay service settings on the Google Apps documentation. Note that SMTP relaying through Google Apps is only allowed through ports 465 or 587. Port 25 is not supported through Google Apps.
If you plan to use a custom port, use the documentation specific to your email service to configure a custom email port.