https://github.com/fgribreau/smtp-to-sendgrid-gateway
Forward emails from SMTP requests to the Sendgrid API. Useful when the cloud provider does not allow outbound connections on ports 25, 465, 587.
https://github.com/fgribreau/smtp-to-sendgrid-gateway
gateway sendgrid smtp
Last synced: 3 months ago
JSON representation
Forward emails from SMTP requests to the Sendgrid API. Useful when the cloud provider does not allow outbound connections on ports 25, 465, 587.
- Host: GitHub
- URL: https://github.com/fgribreau/smtp-to-sendgrid-gateway
- Owner: FGRibreau
- License: mit
- Created: 2017-09-03T07:45:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-17T15:30:33.000Z (about 2 years ago)
- Last Synced: 2025-03-16T10:35:08.677Z (3 months ago)
- Topics: gateway, sendgrid, smtp
- Language: JavaScript
- Size: 200 KB
- Stars: 12
- Watchers: 1
- Forks: 10
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SMTP to SendGrid Gateway
[](https://circleci.com/gh/FGRibreau/smtp-to-sendgrid-gateway/) [](https://david-dm.org/FGRibreau/smtp-to-sendgrid-gateway) [](http://badge.fury.io/js/smtp-to-sendgrid-gateway) [](https://hub.docker.com/r/fgribreau/ssmtp-to-sendgrid-gateway) [](https://hub.docker.com/r/fgribreau/smtp-to-sendgrid-gateway) [](https://hub.docker.com/r/fgribreau/smtp-to-sendgrid-gateway)
[](https://www.codementor.io/francois-guillaume-ribreau?utm_source=github&utm_medium=button&utm_term=francois-guillaume-ribreau&utm_campaign=github) [](http://bit.ly/2c7uFJq)  [](https://join.slack.com/t/fgribreau/shared_invite/zt-edpjwt2t-Zh39mDUMNQ0QOr9qOj~jrg)
Forward emails from SMTP requests to the Sendgrid API. Useful when the cloud provider does not allow outbound connections on ports 25, 465, 587.
### The Story
It all started with [this](https://cloud.google.com/compute/docs/tutorials/sending-mail/):
> Google Compute Engine does not allow outbound connections on ports 25, 465, and 587. By default, these 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, Mailgun, or Mailjet relieves Compute Engine and you from maintaining IP reputation with your receivers.
And since we were on a MVP startup weekend working on our next product [killbug](https://killbug.today), we [tweet](https://twitter.com/FGRibreau/status/904094492197834752) this:
> GKE does not allow outbound connections on ports 25, 465, 587. Keycloak requires SMTP. I need to build a SMTP to SendGrid API gateway.
Here we are.
## Run
Since this server should run as *a sidekick of the main application* (thus on the same machine or [the same pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#understanding-pods)) authorization was not required.
```shell
docker run -it -p 25:25 -e SENDGRID_API=XXXXXXX fgribreau/smtp-to-sendgrid-gateway
```### Configuration - environment variables
- `SENDGRID_API` (required): sendgrid API token
- `SMTP_PORT` (optional) Port to listen (default: 25)## Credits
- [SMTP server](https://nodemailer.com/extras/smtp-server/)
- [mailparser](https://nodemailer.com/extras/mailparser/)
- [@sendgrid/mail](https://www.npmjs.com/package/@sendgrid/mail)