No commit activity in last 3 years
No release in over 3 years
Serialize and enqueue deliveries for existing mailers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

ActionMailer::Enqueable

Drop in support for using queues with existing delivery methods. Works with mailers that accept ActiveRecord, and simple JSON-compatible objects as arguments.

Installation

Add this line to your application's Gemfile:

gem 'action_mailer-enqueable'

Usage

class EnqueableMailer < ActionMailer::Base
  extend ActionMailer::Enqueable

  self.queue = MailRenderingJob

  def welcome(user)
    recipients   'You'
    from         'Me'

    body "Email: Hello, #{user}"
  end

end

class MailRenderingJob

  def self.enqueue(deferred)
    Resque.enqueue(deferred.encoded)
  end
  
  def self.work(params)
    deferred = ActionMailer::Enqueable::Deferred.from_hash(params)
    deferred.mailer.deliver!
  end

end