Skip to content

How To: Send devise emails in background (Resque, Sidekiq and Delayed::Job)

mhfs edited this page May 16, 2012 · 9 revisions

Since sending email synchronously is not a good idea, you'll probably want to have Devise enqueuing it's notification emails for background processing.

Although Devise doesn't support this out of the box you can achieve it easily by using the devise-async gem.

To do so, first add it to your Gemfile:

gem "devise-async"

Then tell Devise to use the proxy mailer in config/initializers/devise.rb:

# Configure the class responsible to send e-mails.
config.mailer = "DeviseAsync::Proxy"

And last but not least, set your queuing backend by creating config/initializers/devise_async.rb:

# Supported options: :resque, :sidekiq, :delayed_job
DeviseAsync.backend = :resque

Your notification emails should now be gracefully enqueued for background processing.

Clone this wiki locally