Notifications in web apps: Mailgun and Twilio

Home » Blog » Software » Web Applications » Notifications in web apps: Mailgun and Twilio

If you want your web app to notify your users upon specific actions or events Mailgun and Twilio are great solutions for doing so.

The former allows you to – among various other features involving eMail – send eMails via a nice and simple REST API. This is particularly handy because you don’t have to worry anymore about delivering eMail asynchronously in order not to delay user actions in the browser. For example, with Mailgun you can simply commit a registration confirmation eMail to their REST API once a user registers without delaying the browser response shown to the user.

Twilio in turn, lets you – again amongst various other telephony-related features – send text messages via SMS, which is great for informing users about urgent events.

There’s lots to be told about both services and how to use them but I found this Mailgun-related tip to especially useful:

How to send a String as an attachment with the Mailgun API and RestClient

Monkey-patching Ruby’s StringIO class this way allows you to generate eMail attachments on the fly with no need to save them as temporary files that clutter your file system (which you – depending on your environment – might not even be allowed to do, Heroku restricts access to the actual file system, for instance).

About the author: Bjoern
Independent IT consultant, entrepreneur

Leave a Comment