Class: FlashFlow::Mailer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/flash_flow/mailer.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Base

Returns a new instance of Base.



7
8
9
10
11
12
13
# File 'lib/flash_flow/mailer.rb', line 7

def initialize(config)
  unless config&.fetch('settings', false)
    raise RuntimeError.new("smtp settings must be set in your flash flow config.")
  end

  configure!(config['settings'])
end

Instance Method Details

#deliver!(type, data = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/flash_flow/mailer.rb', line 15

def deliver!(type, data={})
  delivery_info = get_delivery_info(type)

  if delivery_info
    delivery_info["body_html"] = body_html(data, delivery_info["body_file"])

    Mail.deliver do
      from     delivery_info["from"]
      to       delivery_info["to"]
      cc       delivery_info["cc"]
      subject  delivery_info["subject"]
      body     delivery_info["body_html"]
    end
  end
end