Class: CommandTower::Messaging::ChannelMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/command_tower/messaging/channel_mailer.rb

Constant Summary

Constants inherited from ApplicationMailer

ApplicationMailer::FALLBACK_FROM

Instance Method Summary collapse

Methods inherited from ApplicationMailer

smtp_from_address, #smtp_from_address

Instance Method Details

#deliver_rendered(rendered:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/mailers/command_tower/messaging/channel_mailer.rb', line 6

def deliver_rendered(rendered:)
  unless rendered.is_a?(Rendering::RenderedPayload)
    raise ArgumentError, "rendered must be a RenderedPayload"
  end

  from_address = smtp_from_address

  mail(
    to: rendered.recipient_address,
    from: from_address,
    subject: rendered.subject,
  ) do |format|
    format.text { render plain: rendered.text_body }
    format.html { render html: rendered.html_body.html_safe }
  end
end