Backburner Mailer banner
nesquena nesquena

Backburner Mailer

Communication community

Description

Plugin for sending asynchronous email with Backburner

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

BackburnerMailer

A gem plugin which allows messages prepared by ActionMailer or Padrino Mailer to be delivered asynchronously. Assumes you're using Backburner (http://github.com/nesquena/backburner) for your background jobs.

Note that Backburner::Mailer only works with Rails 3.x and Padrino.

This was **heavily** inspired by and largely adapted from [resque-mailer](https://github.com/zapnap/resque_mailer). Most of the credit goes to them, this is a minor adaptation to support backburner.

Usage

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

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

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

QUEUE=mailer bundle exec rake backburner: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 pass options to backburner, you can specify them as arguments to deliver:

MyMailer.subject_email(params).deliver(:delay => 60, :ttr => 120)

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

# config/initializers/backburner_mailer.rb
Backburner::Mailer.default_queue_name = 'application_specific_mailer'

This is useful when you are running more than one application using backbu