How to change “Devise: password reset instruction email's subject”

前端 未结 6 1604
Happy的楠姐
Happy的楠姐 2020-12-15 03:41

I\'m just unable to change \"password reset instruction\" email\'s subject. I have changed notifer.rb in Mailer to overwrite Devise default email subject. But it\'s not work

6条回答
  •  难免孤独
    2020-12-15 04:26

    I got this to work by creating my own sub-class of Devise::Mailer.

    class DeviseMailer < Devise::Mailer
      def reset_password_instructions(record, token, opts={})
        mail = super
        # your custom logic
        mail.subject = "[SOME DB DATA]"
        mail
      end
    end
    

    And then modifying the devise.rb initializer to use my mailer.

    # Configure the class responsible to send e-mails.
    config.mailer = 'DeviseMailer'
    

提交回复
热议问题