Blog

Friday, August 24, 2012
Mandrill REST API
OK, here's another REST API example. In the same system I blogged about yesterday, I also had to use the Mandrill API to send out some transactional emails. Mandrill is a relatively new service from MailChimp that can be used to send out e-mail via simple API calls. It's pretty nice, and free to use, up to a certain point.

You can actually use it via regular old SMTP, with some control info added into the headers, or you can go ahead and use their REST API. I decided to use the API. Initially, I had no luck with that at all. After thrashing around a bit, I eventually figured out that I had to update to the newest version of EasyHttp. Then, it started working fine, no problem. I didn't bother looking into the internals of EasyHttp to try and figure out what was causing the problem. I'm kind of curious, but, as usual, it's more important to just get the thing working.

So, here's another Gist with some code:

I hope someone finds it useful and/or entertaining.
In this code, I'm sending out two e-mails, one is a trial account activation email, and the other is just a notification to sales. On the first, I'm looking at the errors closely and trying to return a useful error message, so the customer knows that something has gone wrong and has a clue about how to handle it. On the second, I'm less worried about that, as it's just a notification to our salesperson.

Labels: ,

posted by Unknown 7:00 AM
0 comments

Comments: Post a Comment


This page is powered by Blogger. Isn't yours?
© 2011 Andrew Huey