What if SMTP and Sinatra Had a Baby?
Recently I’ve published several posts on the topic of composing software services on top of email. Why this recent obsession?
- People understand the paradigm of email. For some, my grandfather being a prime example, email is their main motivation for having a computer.
- Email is everywhere. It’s cross-platform, cross-device, cross-demographic. It’s estimated that there are nearly two billion email users.
- We’ve only scratched the surface of the types of applications that can be built, using Email as a Service (EaaS, yep worst acronym ever).
It’s this last point that gets me the most excited — and I’m literally so excited I’m yelling as I type right now.
The Problem
Imagine if every time I wanted to rough out a website I had to spin up a whole J2EE stack, gross. In a similar vein, to compose a service on top of email, why should I have to run painful middleware? Quoting the ubuntu community website:
“Setting up an email server is a difficult process involving a number of different programs” yikes!
If only there were a better way!
The Solution (smtproutes)
smtproutes is what you’d get if Sinatra and SMTP had a baby. It’s not an email server with a capital S. smtproutes is a lightweight framework for rapidly prototyping web-services on top of SMTP.
Suppose I wanted to create an email service which lets you subscribe and unsubscribe to a mailing list. Here’s how we’d build this service using the smtproutes framework:
easy_install smtproutes
If the route regular expression is matched by the To: field of an inbound email message, the corresponding method will be executed.
In this example:
- mailing subscribe-username@example.com will add the user, identified by username in the regular expression, to the subscribers collection.
- mailing unsubscribe@example.com will remove the user.
It’s my hope that smtproutes can be a valuable tool for helping developers rapidly compose applications on top of SMTP. You can checkout some of its more advanced features, and contribute here:
https://github.com/bcoe/smtproutes
— Ben (@benjamincoe)