ActionMailer 回调

ActionMailer 支持三个回调

  • before_action
  • after_action
  • around_action

在你的 Mailer 类中提供这些

class UserMailer < ApplicationMailer
  after_action :set_delivery_options, :prevent_delivery_to_guests, :set_business_headers

然后在 private 关键字下创建这些方法

private
  def set_delivery_options
  end

  def prevent_delivery_to_guests
  end

  def set_business_headers
  end
end