Class: Hato::Plugin::Mail

Inherits:
Base
  • Object
show all
Defined in:
lib/hato/plugin/mail.rb,
lib/hato/plugin/mail/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#notify(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/hato/plugin/mail.rb', line 10

def notify(args)
  if smtp_opts = config.smtp
    ::Mail.defaults do
      delivery_method :smtp, (
        smtp_opts.to_hash.keys.inject({}) { |opts, key|
          opts[key.to_sym] = smtp_opts.send(key.to_sym)
          opts
        }
      )
    end
  end

  to_addresses = config.message['to']
  to_addresses = [to_addresses] if to_addresses.is_a?(String)

  to_addresses.each do |to_address|
    send_mail(to_address, args)
  end
end