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