How to intercept ActionMailer's messages on rails 3?

空扰寡人 提交于 2019-12-04 12:00:00
Winfield

It sounds like it might be an order of operations problem.

Have you considered putting the entire code block you referenced in an initializer like config/initializers/mail_hook.rb?

If that premailer plugin works, the only difference I can think of is when the interception hook is registered in the app initialization process.

see RailsCast or AsciiCast Episode #206

http://railscasts.com/episodes/206-action-mailer-in-rails-3

http://asciicasts.com/episodes/206-action-mailer-in-rails-3

Relevant part from the first episode,

/lib/development_mail_interceptor.rb

class DevelopmentMailInterceptor
  def self.delivering_email(message)
    message.subject = "[#{message.to}] #{message.subject}"
    message.to = "eifion@asciicasts.com"
  end
end

/config/initializers/setup_mail.rb

Mail.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!