Class: Mechmarket::Alert

Inherits:
Object
  • Object
show all
Defined in:
lib/mechmarket/alert.rb

Class Method Summary collapse

Class Method Details

.deliver(config:, subject:, body:) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/mechmarket/alert.rb', line 5

def self.deliver(config:, subject:, body:)
  Mail.defaults do
    delivery_method(
      :smtp,
      address: 'smtp.gmail.com',
      port: 587,
      user_name: config.username,
      password: config.password,
      authentication: 'plain',
      enable_starttls_auto: true
    )
  end

  from = "#{config.username}@gmail.com"
  to   = "Me <#{from}>"

  # @TODO: Check for errors.
  Mail.deliver do
    from from
    to to
    subject subject
    body body
  end

  true
end