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:
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).