Sending delayed email from devise

后端 未结 4 1890
长情又很酷
长情又很酷 2021-02-03 13:43

Is there a simple way of telling Devise to send all email via delayed_job?

4条回答
  •  太阳男子
    2021-02-03 14:32

    I found that none of the above worked for me. I'm using Devise 2.0.4 and Rails 3.2.2 with delayed_job_active_record 0.3.2

    The way devise actually talks about doing something like this in the comments in the code is to override the methods in the User class. Thus, I solved it like so, and it works perfectly:

    app/models/User.rb

    def send_on_create_confirmation_instructions
      Devise::Mailer.delay.confirmation_instructions(self)
    end
    def send_reset_password_instructions
      Devise::Mailer.delay.reset_password_instructions(self)
    end
    def send_unlock_instructions
      Devise::Mailer.delay.unlock_instructions(self)
    end
    

提交回复
热议问题