有人能向我解释一下在哪里可以找到关于属性delivery_handler的具体解释吗?什么样的东西?一根绳子?或者别的什么?
以及该指令是如何工作的:
filteredMailers.include?(message.delivery_handler)我是从一个邮件观察者上下文那里得到的:
class DevelopmentMailInterceptor
def self.delivering_email(message)
filteredMailers = %w[
NotificationMailer
]
if filteredMailers.include?(message.delivery_handler)
message.subject = "[filter] To:#{message.to} - #{message.subjec}"
message.to = 'logs@mail.com'
end
return message
end
end我为消息类找到了这个参考文献,但是它仍然非常困惑于什么类型的对象是delivery_handler。
欢迎任何帮助。谢谢你的解释。
发布于 2014-08-28 20:15:24
它被记录在https://github.com/mikel/mail/blob/2.6.1/lib/mail/message.rb#L138
您应该为它分配一个类,该类实现一个deliver_mail方法,该方法可以/应该执行以下任何操作(引用自上面的链接):
# * Appending the mail object to Mail.deliveries as you see fit.
# * Checking the mail.perform_deliveries flag to decide if you should
# actually call :deliver! the mail object or not.
# * Checking the mail.raise_delivery_errors flag to decide if you
# should raise delivery errors if they occur.
# * Actually calling :deliver! (with the bang) on the mail object to
# get it to deliver itself.您也可以调用deliver!,而不是调用yield,这将告诉邮件调用自己的私有do_delivery方法。
ActionMailer为它分配了mailer类(即MyMailer in class MyMailer < ActionMailer::Base) 来源,然后依赖于ActionMailer::Base的delivery_mail实现(除非您选择覆盖它)。
https://stackoverflow.com/questions/19477431
复制相似问题