Menu

Back Home

Rails mass mailing – it shouldn’t be this complicated

The requests we get from our clients for “social networking” type tools and features has grown exponentially over the past two years. To make a user experience relevant, easy, secure, means that an application will need to send email notifications to that user (to register, to tell them of friend’s messages, to send them newsletters or updates, to send tickets, calendar bookings .. the list goes on).

Why is this a problem?
Because sending an email is not an instantaneous action. The more emails you try to send, the longer you may have to wait as the application sends them. Imagine an app that lets you invite 300 friends to an event. Multiply this with 300 people sending the same invite to their friends.

While Rails was kind enough to provide a simple way to send emails, it left out one important detail. You can only send one at a time!

If you find yourself in the unfortunate position where you need to mass mail then you’re on your own. So what do you do? You Google around of course. Someone is bound to have figured this one out.

It looks like there are 3 ways to solve this:

1. Use existing email marketing services

You can go with this option. There are plenty out there: Mail Chimp, Constant Contact, Thin Data, Campaign Monitor, Campaigner and others. All you need to do is generate some kind of mailing list and import it into one of these systems and then keep it up to date. But that’s not always practical. Not if you want your users to be able to initiate the mass mailing by themselves.  Don’t get me wrong, these services are great at what they do, but what we really want to do is to send mass emails from our own app.

2. Use existing code

If you really want your Rails app to be able to send mass mails at a click of a button you can try using Eric Hodel’s ar_mailer which is on version 1.4.0 as of June 2009. This has the advantage of letting you use the email addresses that you already have on your system (no exporting and importing to a different system) but before you get to that you still have to integrate it with whatever version of Rails you happen to be using.  Assuming you get it working properly, now you have a brand new background process to take care of.

Ar_mailer is great but leaves you half way there.

* The queue is not smart enough to prioritize emails. If one user sends 5000 invitations and after that another user wants to recover his password, he’ll have to wait until all 5000 emails are sent before he gets his password back. The users receiving the invitation won’t notice if  it takes a bit longer to reach them, but the guy that is trying to recover his password will be upset if he doesn’t get it right away. This is obviously not good enough.
* How do you monitor if an email has been sent or failed?
* If you have an email template and your client wants to change it all the time, what do you do?

3. Build it all from scratch

Even if you decide to do it yourself from scratch you’ll still need a queue to store the emails that will be sent at some time in the near future by another process running in the background. From there on, it depends on what you really need. Be prepared to put aside some extra time because it ain’t simple.

So what would be the perfect solution? Simply put: I don’t want to have to worry about it. I want to be able to say: “Here’s my email, here’s the list of people I want it sent to. Go and do it … please”.

Wouldn’t that be great? Sure it would! We’ve encountered this problem enough times to make us want to solve it for good.

And so we’ve set out to build it and this is what we think a mass mailing solution:

  1. I want to be able to use it independently of the language I’m coding in – it needs to have an API
  2. I want to be able to use the same code I have right now (layouts, email templates, etc.) – it needs to integrate easily
  3. I want to know if a specific email was sent, failed or if it hasn’t been sent yet and I want to know why – it needs reporting
  4. If a client complains that the emails aren’t rendering correctly I want to be able to see what they are receiving – it needs to let me look at the emails sent
  5. I want to be able to easily resend any email – it needs to let me act on it
  6. I want to create and manage email templates so that my client can edit them without asking me every time and without forcing me to change the code and to deploy my app all over again – it needs an optional template management system.
  7. I want the queue system to be smart enough to distinguish between a single email and a batch of 5000 emails and prioritize them accordingly – it needs a smart queue system.
  8. And most importantly, how can all of this be done with minimal effort to set it up each time I create a new app. – it needs a plugin.

Postage App!

Mass mailing app

We are currently developing this system which will help us build better apps. We’re building it according to our needs and we think that these might also be the needs of other developers out there. Check it out and sign up for an update on the developer free release!

10 Responses to Rails mass mailing – it shouldn’t be this complicated

  1. MIchael Troy says:

    Wow. This is so cool. I ran into this exact same bunch of issues some time back. I ended up using @adzap’s ar_mailer http://github.com/adzap/ar_mailer

    It basically either stores email in the db or sends them immediately. Perfect for user signups and newsletters. Now user signup email does not get queued behind a newsletter.

  2. pierre says:

    I know of only one bird – the parrot – that talks; and it can’t fly very high.

  3. srinivas says:

    Nice illustrations..

  4. srinivas says:

    Who draw this sketch

  5. Will says:

    Jack, your solution *sounds* great. But in your blog post you mention sending 5000 emails… however your solution only supports 500 mails per day. So it would take me 10 days in your own example to mail my users. I dont get it. If you support more than 500 why is it not listed on a pricing page or something on your site?

    We have lists with between 3000-40,000 users. Can your service handle it? How much is it? If you are charging how are you different from mailchimp and the other guys? If your limit is 500 that should be clear on all your posts.

    Thanks

  6. Andrew Pelt says:

    I want to say – thank you for this!

  7. interniści says:

    i know this is not exactly on topic, but i have a blog using the blogengine platform as well and i’m having issues with my comments displaying. is there a setting i am forgetting? maybe you could help me out? thank you.

  8. Thanks for emphasizing this issue.

  9. Jack says:

    Hi guys, can you please post issues related to PostageApp in http://help.postageapp.com so they can be properly addressed.
    Thank you.

  10. A big heads up for your clarifying articles this unique data quite usefull!!! I’ll share this with all of my friends!! Keep up the good work!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>