←back to thread

298 points mooreds | 6 comments | | HN request time: 0.831s | source | bottom
1. Onavo ◴[] No.42178720[source]
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?
replies(4): >>42179103 #>>42179588 #>>42179838 #>>42183360 #
2. jedberg ◴[] No.42179103[source]
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.

replies(1): >>42179387 #
3. Onavo ◴[] No.42179387[source]
What about a fly.io container?
4. aforwardslash ◴[] No.42179588[source]
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.

5. kilroy123 ◴[] No.42179838[source]
For my site https://aichat.email this is how I do this:

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

6. patja ◴[] No.42183360[source]
I didn't think SES received. It's just a sender.

I run postfix.