Question: I want to know how to setup a mail server like postfix on Google VP instance.

I'm running Ubuntu 16.04 (and LAMP stack) and can't get the mail server to send email from website.

I have installed postfix, and opened port 25, but no luck.

Any ideas on how to proceed?

Error logs: Network is unreachable and Connection timed out

Answer: 
According to <https://cloud.google.com/compute/docs/tutorials/sending-mail/>, you cannot set up a mail server the usual way, as ports 25, 465 and 587 are blocked for outbound connections on Google Cloud. Instead, you might take a look at relaying services such as [Mailgun](https://mailgun.com) or [SendGrid](https://sendgrid.net), which allow sending through port 2525 or an API instead. These services might cost a little bit of money, however.
Update to @XanderSmeets answer:

> 
> Due to the risk of abuse, connections to destination TCP Port 25 are
> always blocked when the destination is external to your VPC network.
> This includes using SMTP relay with Google Workspace.
> 
> 
> Google Cloud does not place any restrictions on traffic sent to
> external destination IP addresses using destination TCP ports 587 or
> 465. The implied allow egress firewall rule allows this traffic unless you've created egress deny firewall rules that block it.
> 
> 
> 

Source:

<https://cloud.google.com/compute/docs/tutorials/sending-mail/>