ActionMailer::Parameterized

module ActionMailer::Parameterized

Provides the option to parameterize mailers in order to share instance variable setup, processing, and common headers.

Consider this example that does not use parameterization:

class InvitationsMailer < ApplicationMailer
  def account_invitation(inviter, invitee)
    @account = inviter.account
    @inviter = inviter
    @invitee = invitee

    subject = "#{@inviter.name} invited you to their Basecamp (#{@account.name})"

    mail        subject:   subject,
      to:        invitee.email_address,
      from:      common_address(inviter),
      reply_to:  inviter.email_address_with_name
  end

  def project_invitation(project, inviter, invitee)
    @account = inviter.account
    @project = project
    @inviter = inviter
    @invitee = invitee
    @summarizer = ProjectInvitationSummarizer.new(@project.buc