Glenn Gillen

Managing email lists with Mailchimp and MonkeyWrench

Most of my projects and clients have a need to send email to the users to inform them of updates to the system, inform them of special marketing offers, or other such broadcast messages. Unfortunately, these type of messages can flag up warnings with many mail servers as your message may never arrive at the recipient. There are numerous providers out there that do what they can to make it easier, and most do a respectable job (I think I've used almost all of them at some stage). Mailchimp (or here via an affiliate link) has proven to be the best for my purposes to date.

They have a really rich and well documented API, a pretty good admin interface (although the bar is set pretty low here by most competitors), and they're free to use until you get over 500 users. And even then they're pretty good value for what you get.

Introducing MonkeyWrench

Over a year ago now I started first started integrating my apps to using Mailchimp, and while it was quite easy I did occasionally run into problems. The ruby APIs were just thin layer atop the Mailchimp API and it didn't feel natural, plus there were a range of edge cases that were non-obvious unless you were hanging out in the dev forums or using the API a lot (like the fact that you can't batch subscribe members to a list and send them a welcome email).

So I wrote MonkeyWrench to overcome these shortcomings. It feels more natural to use within a ruby app, and it will automatically process large actions in batches, subscribe members as a list in batch if possible but do them individually if that is what is required. It's all an attempt to make interacting with with your users as simple as possible.

It's in production use for a number of clients, and significant portions of the codebase have been contributed/improved upon by David Heath who I've been working with at Wordtracker.

To give an example of how to use it, I'm going to just paste some of the README in here.

Getting Started

To get started, you need to first connect to the appropriate datacenter with your API key:

1
2
MonkeyWrench::Config.new(:datacenter => "us1", 
                         :apikey => "your-api-key-goes-here")

From there you've got a rich API for managing Lists and Members. To subscribe a new user to a list simply do the following:

1
2
list = MonkeyWrench::List.find_by_name("My Example List")
list.subscribe("[email protected]")

Taking it Further

Code is available at GitHub, documentation is an evolving affair (all of the List methods are documented). I'm more than happy to receive patches for any functionality that isn't covered, we've only really implemented what we've needed to date. Just fork it, make a test, and send me a pull request with the patch.

Glenn Gillen

I'm an advisor to, and investor in, early-stage tech startups. Beyond that I'm an incredibly fortunate husband and father. Working on a developer-facing tool or service? Thinking about starting one? Email me and let me know or come to one of our days to help make it a reality.