Sending devise emails using resque does not work out of the box with devise and resque_mailer. There are a few purported solutions online that don't work.
Below are 2 ways to make it work. Either way, I'll assume you already have devise and resque working with this in your Gemfile:
Tell Devise you are going to use a different mailer in config/initializers/devise.rb:
Now create the DeviseResqueMailer class. Here are 2 alternate ways to make it happen:
1. Copy/Paste FTW
Add lib/devise_resque_mailer.rb:
2. Use a new module in resque_mailer:
Use this fork of resque_mailer: http://github.com/teeparham/resque_mailer/tree/model-mailer . Specify that fork in your Gemfile:
gem 'resque_mailer', :git => 'git://github.com/teeparham/resque_mailer'
You'll now have an additional model available called Resque::ModelMailer. Include that in a new mailer (again, lib/devise_resque_mailer.rb):
For either #1 or #2, If you use a mailer class called DeviseResqueMailer, the view files for the mailer need to be in the expected place. Move your devise views from app/views/devise/mailer/ to app/views/devise_resque_mailer/.
You should now be able to send emails directly in development, or using resque in production.
Why is this necessary?
The devise mailer takes a resource (typically a user) as the argument to all its mailer actions. ResqueMailer repurposes the Mailer class as a Resque Job class. Enqueuing a job with an argument of an object (a user) is not advised since the marshaling and unmarshaling of that object may not be well-defined since it must be stored in redis as a primitive type. Essentially what we're doing is queuing a resque job of the DeviseResqueMailer class with the class name and id ("User", 123 for example) instead of the object itself. Then when the job is performed, we call User.find(123) and pass that to the mail action.