Module: MailtoHelper

Defined in:
app/helpers/mailto_helper.rb

Overview

Make it a little easier to integrate email into support flows, etc.

Instance Method Summary collapse

Instance Method Details

#mail_to_template(template, text, **kwargs) ⇒ Object



3
4
5
6
7
8
9
# File 'app/helpers/mailto_helper.rb', line 3

def mail_to_template(template, text, **kwargs)
  contents = File.read Rails.root.join("app/mailtos/#{template}.txt.erb")
  parser = Mailto::Frontmatter.new render inline: contents
  data = parser.data.merge("body": parser.body)
  email = data.delete("to")
  mail_to email, text, **data.merge(kwargs)
end