smtp relay for google compute engine

Solution 1:

Have a look at the error message:

Aug 1 20:29:33 xblgx-ops postfix/smtp[30910]: BA3D73F79F: to=, relay=smtp-relay.gmail.com[74.125.195.28]:587, delay=0.49, delays=0.03/0.02/0.39/0.05, dsn=5.7.0, status=bounced (host smtp-relay.gmail.com[74.125.195.28] said: 550-5.7.0 Mail relay denied [35.230.53.86]. Invalid credentials for relay for 550-5.7.0 one of the domains in: insidexblgx.internal, c.insidexblgx.internal, 550-5.7.0 xblgx-ops.c.insidexblgx.internal, xbiologix.net (as obtained from 550-5.7.0 HELO and MAIL FROM). 550-5.7.0 Email is being sent from a domain or IP address which isn't registered 550-5.7.0 in your G Suite account. Please login to your G Suite account and 550-5.7.0 verify that your sending device IP address has been registered within 550-5.7.0 the G Suite SMTP Relay Settings. For more information, please visit 550 5.7.0 https://support.google.com/a/answer/6140680#maildenied m11sm1647381ooe.3 - gsmtp (in reply to MAIL FROM command))

This behavior explained at the documentation Sending email from an instance:

... if you are familiar with G Suite and are already paying for a G Suite account that supports email, you can set up a relay service to send email through G Suite. Note that Gmail and G Suite enforce limits for email activity.

If you don't have a G Suite account or don't want to use G Suite or a third-party mail provider, you can set up your own email server on an instance using a non-standard port. You can choose any ephemeral port that isn't blocked by Compute Engine.

  • To use SendGrid, Mailgun, or Mailjet: Follow the instructions for Sending Email using SendGrid, Sending Email using Mailgun, or Sending Email using Mailjet.
  • To use a G Suite domain: Follow the instructions for SMTP relay service settings in the G Suite documentation. SMTP relaying through G Suite is only allowed through ports 465 or 587. Port 25 is not supported through G Suite.

also, at the section Using standard email ports:

By default, Compute Engine allows outbound connections on all ports but port 25, which is blocked because of the risk of abuse. All other ports are open, including ports 587 and 465.

and at the RFC 5321:

4.5.4.2. Receiving Strategy

The SMTP server SHOULD attempt to keep a pending listen on the SMTP port (specified by IANA as port 25) at all times. This requires the support of multiple incoming TCP connections for SMTP.

As you can see, accordingly to the documentation and RFC you can reach your goal in the 2 ways: using your paid GSuite account or using paid 3rd party services.

In addition, you can try to configure relay via your existing smtp server based on Postfix that you mentioned above.