Hacker News new | ask | show | jobs
by Onavo 584 days ago
What’s the easiest way to receive email programmatically without having to resort to a hosted service like SES? Is the SMTP protocol simple enough that it can be implemented in for example a serverless lambda?
4 comments

The easy answer is to use an smtp server; many languages have stable packages to implement that. You can also use postfix with procmail or exim - leave the smtp stuff to tried and true packages, and have your code receive messages either via maildir or direct scripting.

The long answer is: first make sure you don't have a blacklisted IP; ask your cloud provider for permission to enable an MTA (mail transfer agent) and have fun seeing 99% of your email traffic being either brute force auth attempts or spam delivery attempts.

The protocol is quite simple to implement. The tricky part is triggering the lambda and then holding the connection open long enough to get the message.

You can’t trigger a lambda directly via tcp. You’d have to go through a gateway. That gateway would have to hold both sides of the connection open for a pretty long time.

It would be tricky but doable.

What about a fly.io container?
For my site https://aichat.email this is how I do this:

SendGrid Inbound Parse --> node.js server --> back to user

I didn't think SES received. It's just a sender.

I run postfix.