README.md

ResqueMailer

A gem plugin which allows messages prepared by ActionMailer to be delivered
asynchronously. Assumes you're using Resque (http://github.com/defunkt/resque)
for your background jobs.

Note that recent (2.0+) versions of Resque::Mailer only work with Rails 3.x.
For a version compatible with Rails 2, specify v1.x in your Gemfile.

Usage

Include Resque::Mailer in your ActionMailer subclass(es) like this:

class MyMailer < ActionMailer::Base
include Resque::Mailer
end

Now, when MyMailer.subject_email(params).deliver is called, an entry
will be created in the job queue. Your Resque workers will be able to deliver
this message for you. The queue we're using is imaginatively named +mailer+,
so just make sure your workers know about it and are loading your environment:

QUEUE=mailer rake environment resque:work

Note that you can still have mail delivered synchronously by using the bang
method variant:

MyMailer.subject_email(params).deliver!

Oh, by the way. Don't forget that your async mailer jobs will be processed by
a separate worker. This means that you should resist the temptation to pass
database-backed objects as parameters in your mailer and instead pass record
identifiers. Then, in your delivery method, you can look up the record from
the id and use it as needed.

If you want to set a different default queue name for your mailer, you can
change the default_queue_name property like so: