Sidekiq::Mailer
This gem lets you send mail in the background using Sidekiq.
Installation
Add the gem to your Gemfile:
gem 'sidekiq-mailer'
If you're using Bundler 1.0, you'll need to tell Bundler the library file name:
gem 'sidekiq-mailer', :require => 'sidekiq/mailer'
Usage
Install into your mailer:
class BackgroundMailer < ActionMailer::Base
extend Sidekiq::Mailer
def send_mail(record)
mail :to => record.email
end
end
Queue mail jobs using the DelayedJob background mail style:
BackgroundMailer.delay.send_mail(record)
To actually your mail, run sidekiq
. If you set your mail queue name to "mail", run sidekiq -q mail
instead.
Caveats
Right now, it only expects a single ActiveRecord instance as the argument passed to whatever email method you call. This could become a problem in the future, but it's working for me. If it's a problem for you, see the next section. :)
Contributing
Please do, pull requests happily discussed and accepted.