Newy
Newy

Reputation: 40107

Asynchronous Actionmailer in Rails

I've noticed some of my actions (on a development environment) take a little while to load up as an email they require an email notification (through Google's servers). Do I need to implement asynchronous handling of emails like - http://upstream-berlin.com/2008/05/19/new-rails-plugin-for-making-actionmailer-asynchronous/

Upvotes: 1

Views: 7076

Answers (2)

Dan Gebhardt
Dan Gebhardt

Reputation: 3281

I've just released a gem, Mailhopper, that queues email in your database for asynchronous sending plus optional archiving. A second gem, DelayedMailhopper, queues and sends these emails using DelayedJob.

I developed this approach to be more robust than DelayedJob alone, as explained here:

http://www.cerebris.com/blog/2011/09/07/tame-rails-email-dragons-with-mailhopper/

Upvotes: 1

Olly
Olly

Reputation: 7758

Offloading potentially long-running tasks such as sending emails in to the background is a good idea to improve the responsiveness of your application, albeit by sacrificing the simplicity of your application a little.

One popular way to do this (which I have used with great success) is using Delayed Job. The README file contains examples of how simple it is to send email in the background -- basically you just use the send_later method.

Here's a link to another good tutorial:

http://railstips.org/2008/11/19/delayed-gratification-with-rails

Upvotes: 8

Related Questions