Class: EcoRake::Utils::Mailer::AwsProvider

Inherits:
ProviderBase show all
Defined in:
lib/eco-rake/utils/mailer/aws_provider.rb

Instance Method Summary collapse

Methods inherited from ProviderBase

#fetch_to, to_desc

Instance Method Details

#configured?Boolean

Returns whether or not the mailer is configured for usage.

Returns:

  • (Boolean)

    whether or not the mailer is configured for usage.



28
29
30
# File 'lib/eco-rake/utils/mailer/aws_provider.rb', line 28

def configured?
  fetch_access_key_id && fetch_secret_access_key && fetch_region
end

#send_mail(subject:, body:, to: nil, cc: nil, bcc: nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/eco-rake/utils/mailer/aws_provider.rb', line 6

def send_mail(subject:, body:, to: nil, cc: nil, bcc: nil)
  ses.send_email(
    destination: fetch_destination(to: to, cc: cc, bcc: bcc),
    source:      fetch_from,
    message:     {
      subject: {
        charset: "UTF-8",
        data:    subject
      },
      body:    {
        # NOTE: (html) will let you send html instead
        # you can use both at once if you like
        text: {
          charset: "UTF-8",
          data:    body
        }
      }
    }
  )
end