Google Cloud Platform (GCP) blocks outbound traffic on port 25 by default to prevent spam and abuse. This means that you cannot send emails directly from your GCP project using port 25.
There are two main ways to send emails from GCP without using port 25:
- Use a third-party email service such as SendGrid or Mailgun.
- Use the Gmail SMTP server.
Using a third-party email service
To use a third-party email service, you will need to create an account with the service and then configure your GCP project to use the service’s SMTP server.
Using the Gmail SMTP server
To use the Gmail SMTP server, you will need to create a Google Workspace account and then configure your GCP project to use the Gmail SMTP server.
Once you have configured your GCP project to use an email service, you can then send emails from your application using the email service’s API or SDK.
Which option should you choose?
The best option for you will depend on your specific needs and requirements. If you need to send a large volume of emails, or if you need to send emails with complex formatting, then using a third-party email service may be the best option. If you only need to send a small number of emails, or if you need to send emails with simple formatting, then using the Gmail SMTP server may be the best option.
Additional considerations
If you are using a third-party email service, you will need to factor in the cost of the service. Most third-party email services offer a free tier, but they may also charge for additional features or for sending a large volume of emails.
If you are using the Gmail SMTP server, you will need to make sure that your GCP project is authorized to use the server. You can do this by creating a Google Workspace account and then configuring your GCP project to use the Gmail SMTP server.
Conclusion
There are two main ways to send emails from GCP without using port 25: using a third-party email service or using the Gmail SMTP server. The best option for you will depend on your specific needs and requirements.