Module: Marfa::Helpers::Email
- Defined in:
- lib/marfa/helpers/email.rb
Overview
Provide helpers for Sinatra controllers
Instance Method Summary collapse
-
#send_email(options) ⇒ Object
Send email using mailbox config @example: send_email({ template: ‘mail’, to: ‘[email protected]’, mailbox: :admin, subject: ‘Hello’, data: { title: ‘Hello!’ } }).
Instance Method Details
#send_email(options) ⇒ Object
Send email using mailbox config @example:
send_email({ template: 'mail', to: '[email protected]', mailbox: :admin, subject: 'Hello', data: { title: 'Hello!' } })
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/marfa/helpers/email.rb', line 13 def send_email() mailbox = [:mailbox] || :default config = Marfa.config.email[mailbox] return if config.nil? template_engine = Marfa.config.template_engine || :haml body = render(template_engine, :"#{[:template]}", locals: [:data], layout: false) Pony. = { via: :smtp, via_options: config } mail = { to: [:to], subject: [:subject], html_body: body } mail[:from] = config[:from] unless config[:from].nil? Pony.mail(mail) end |