Class: Mailkick::Service::AwsSes

Inherits:
Mailkick::Service show all
Defined in:
lib/mailkick/service/aws_ses.rb

Constant Summary collapse

REASONS_MAP =
{
  "BOUNCE" => "bounce",
  "COMPLAINT" => "spam"
}

Constants inherited from Mailkick::Service

Sendgrid

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mailkick::Service

#fetch_opt_outs

Constructor Details

#initialize(options = {}) ⇒ AwsSes

Returns a new instance of AwsSes.



11
12
13
# File 'lib/mailkick/service/aws_ses.rb', line 11

def initialize(options = {})
  @options = options
end

Class Method Details

.discoverable?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/mailkick/service/aws_ses.rb', line 36

def self.discoverable?
  !!defined?(::Aws::SESV2::Client)
end

Instance Method Details

#opt_outsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mailkick/service/aws_ses.rb', line 15

def opt_outs
  response = client.list_suppressed_destinations({
    reasons: ["BOUNCE", "COMPLAINT"],
    # TODO make configurable
    start_date: Time.now - (86400 * 365),
    end_date: Time.now
  })

  opt_outs = []
  response.each do |page|
    page.suppressed_destination_summaries.each do |record|
      opt_outs << {
        email: record.email_address,
        time: record.last_update_time,
        reason: REASONS_MAP[record.reason]
      }
    end
  end
  opt_outs
end