How to receive emails programmatically

Gunar Gessner

Gunar Gessner

Jun 22, 2020

tl;dr See the library @gunar/email-to-webhook. If you need outgoing emails, use mailgun.

I don't know about you, but for me anything dealing with SMTP seems really hard. Well, not anymore, since I have gone thorugh this journey. But I still think the majority of the developers do not see how easy it can be to run your own email server. At least for incoming emails. Which is the part I'm interested in because automation.

Emails is ubiquitous. We are Software Engineers. We want to automate all the things.

People say that there are reasons why you may not want to run your own mail server. Guess what? These don't apply to receiving emails. Sending emails is though because you don't want your emails to be blocked by SPAM filters. But receiving emails is less complicated.

Mailgun.com is a solid email service. I've used their serivices for many years, at multiple companies. It never failed me. So if you want to make this as easy as possible, simply use their infrastructure. They have UI for routing emails, even to webhooks.

Still with me? Then perhaps you're here because you want to own your data. You want to make sure your incoming emails don't go through datacenters of corporations. Or perhaps you just don't want to pay the $35/mo for the smallest Mailgun plan that includes Incoming Emails.

I've created a package to encapsulate the complexity of receiving emails in the SMTP protocol, and forwarding them to HTTPS. This package is quite small. But it brings to light how setting up such a service is easier than one might assume.

To continue your journey, follow the instructions on @gunar/email-to-webhook/README.md.

Sign up for the newsletter

Read other stuff