【问题标题】:custom confirmation mail with dynamic subject in devise设计中带有动态主题的自定义确认邮件
【发布时间】:2014-11-27 19:29:43
【问题描述】:

我想自定义带有动态内容的设计确认邮件主题。

我试图通过使用link 来实现这一点。

没有变化。它从 devise.en.yml 中获取“确认说明”字符串。然后我在 devise.en.yml 文件中进行了更改。它已经反映出来,但无论如何它是静态的变化。但是我需要用动态的内容来改变主题。

请指导我解决此问题。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 email authentication devise


    【解决方案1】:

    我通过创建Devise::Mailer 的子类解决了这个问题

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

    并在初始化程序中自定义 devise.rb 以调用自定义电子邮件程序

    config.mailer = 'DeviseMailer' 
    

    【讨论】:

    猜你喜欢
    • 2012-09-03
    • 2015-01-05
    • 2013-06-04
    • 2023-03-25
    • 1970-01-01
    • 2016-04-03
    • 2012-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多