Ruby on Rails ActionMailer ActionMailer Callbacks


Example

ActionMailer supports three callbacks

  • before_action
  • after_action
  • around_action

Provide these in your Mailer class

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

Then create these methods under the private keyword

private
  def set_delivery_options
  end

  def prevent_delivery_to_guests
  end

  def set_business_headers
  end
end