Ruby on rails Rails ActionMailer消息确定创建它的邮件程序

Ruby on rails Rails ActionMailer消息确定创建它的邮件程序,ruby-on-rails,ruby-on-rails-3.2,actionmailer,Ruby On Rails,Ruby On Rails 3.2,Actionmailer,ActionMailer通过mail()创建的邮件消息是否有办法确定是哪个mailer方法创建的?假设一个拦截器想要确定它是从哪个mailer和哪个mailer方法发送的,并基于此修改某些内容 假设这封邮件: class ApplicationMailer < ActionMailer::Base def some_mail mail end end 是否有这样的方法,或某种确定方法 更新 更改了问题,以反映现有的delivery\u handler方法如何确定邮寄者,该

ActionMailer通过mail()创建的邮件消息是否有办法确定是哪个mailer方法创建的?假设一个拦截器想要确定它是从哪个mailer和哪个mailer方法发送的,并基于此修改某些内容

假设这封邮件:

class ApplicationMailer < ActionMailer::Base
  def some_mail
    mail
  end
end
是否有这样的方法,或某种确定方法

更新


更改了问题,以反映现有的
delivery\u handler
方法如何确定邮寄者,该问题的答案被标记为重复,但使用的确切邮寄方法仍然未知。

这回答了
delivery\u handler
部分,这是非常棒的。不幸的是,这并不能解决使用特定交付方法的需要。您能否更正“交付处理程序”中的部分问题,使其与上述问题不重复?
class MailInterceptor
  def self.delivering_email(message)

    # `delivery_handler` exists, and answers question of which Mailer was used
    logger.debug "Mailer:         #{message.delivery_handler}" # "ApplicationMailer"
    # NOTE: `method_name` doesn't exist, it shows the desired functionality
    logger.debug "Message Method: #{message.mailer.method_name}" # "some_mail"

    case message.delivery_handler
    when ApplicationMailer
      message.bcc.append "bccmetoo@test.com" if message.mailer.method_name == "some_mail"
    when OtherMailer
      message.bcc.append "bccthisperson@foo.com"
    end
  end
end