European Cloud Solution for sending emails with less headache
I wanted to make a nice, clean open source project. I want it to be small and simple to set up.
What open source projects usually do is have a config for SMTP_HOST, SMTP_PASSWORD etc and then just make it your (the users) problem to deal with this. I have set up my own email infra, I know how to do it, I have gotten it to decent reputation levels, etc, but I wanted something better for the users of my project.
This project also uses convex as the backend, so it is not an unopinionated clump of nodejs, it has certain characteristics that I like. I want the email sending thing to reflect this as well, it needs to be a scalable solution.
But I also felt iffy about sending all my users’ mails to some American company, just so they could log into their account on their own deployment of the open source project. Solutions I evaluated were: Use AWS for everything and then do infra as code on that and set up the email sending there, or pay 20$/mo to resend.com and have them handle the mails for you.
What I did instead is use a european offer called scaleway transactional email service. I did not know these guys existed. Their cloud was easy to sign up for, and their mailing service is just a REST API, and then they take care of delivery as best they can.
I did not even roll my own auth: I am using the auth setup that the convex people came up with.
IMHO that one exists in an interesting spot between hands-off (e.g. clerk) and roll your own. Betterauth is probably better, but I don’t know yet.
I took their Email thing for talking to the https://resend.com/ api and quickly adapted it for my own use. In case this is something you are interested in doing with convex specifically, here is the code: https://github.com/domi-ninja/websites.fail/blob/master/src/lib/auth/ScalewayEmailAuth.ts
Note how it gets used in convex auth setup in the usual way, check their docs for that, etc.
Anybody using my open source project could easily copy paste the Scaleway TEM
rest api call and do their own thing with a different provider, I am sure they exists!
Another alternative, even within convex, would be using node-mailer and talking SMTP to whatever service. I think that might be more brittle, I have seen some deeply unserious email sending services which will bounce/rate limit you etc. and then it becomes a hassle, so let’s not do that here.
TODO in this project (websites.fail):
- Get feedback about email sending success etc from scaleway and do something useful with that. Probably via webhook.
- Make it easy to spin up the convex backed on your own infra