I have just found this interesting project for Rails after a lot of research:

https://github.com/postalserver/postal

I wonder if there are any other promising projects out there. The idea is to have a scalable service like Sendgrid, Postmark or AWS SES, … but self-hosted.