Class: PandaCms::FormMailer

Inherits:
ApplicationMailer show all
Defined in:
app/mailers/panda_cms/form_mailer.rb

Instance Method Summary collapse

Instance Method Details

#notification_email(form:, form_submission:) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/mailers/panda_cms/form_mailer.rb', line 3

def notification_email(form:, form_submission:)
  # TODO: Handle fields named just "name", and "email" better
  @submission_data = form_submission.data
  @sender_name = @submission_data["first_name"].to_s + " " + @submission_data["last_name"].to_s
  @sender_email = @submission_data["email"].to_s

  mail(
    subject: "#{form.name}: #{form_submission.created_at.strftime("%d %b %Y %H:%M")}",
    to: email_address_with_name("[email protected]", "James Inman"),
    from: email_address_with_name("[email protected]", "Panda CMS"),
    reply_to: email_address_with_name(@sender_email, @sender_name),
    track_opens: "true",
    message_stream: "outbound"
  )
end