Class: Aws::ActionMailer::SESV2::Mailer

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/action_mailer/ses_v2/mailer.rb

Overview

Provides a delivery method for ActionMailer that uses Amazon Simple Email Service V2.

Configure a delivery method with:

client_options = { region: 'us-west-2' }
ActionMailer::Base.add_delivery_method :ses_v2, Aws::ActionMailer::SESV2Mailer, **client_options

Client options are used to construct a new Aws::SESV2::Client instance. Once you have a delivery method, you can configure your Rails environment to use it:

config.action_mailer.delivery_method = :ses_v2

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mailer

Returns a new instance of Mailer.

Parameters:



24
25
26
27
# File 'lib/aws/action_mailer/ses_v2/mailer.rb', line 24

def initialize(options = {})
  @client = Aws::SESV2::Client.new(options)
  @client.config.user_agent_frameworks << 'aws-actionmailer-ses'
end

Instance Method Details

#deliver!(message) ⇒ Object

Delivers a Mail::Message object. Called during mail delivery.



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/aws/action_mailer/ses_v2/mailer.rb', line 30

def deliver!(message)
  params = { content: { raw: { data: message.to_s } } }
  params[:from_email_address] = from_email_address(message)
  params[:destination] = {
    to_addresses: to_addresses(message),
    cc_addresses: message.cc,
    bcc_addresses: message.bcc
  }

  @client.send_email(params).tap do |response|
    message.header[:ses_message_id] = response.message_id
  end
end

#settingsHash

Returns:

  • (Hash)


45
46
47
# File 'lib/aws/action_mailer/ses_v2/mailer.rb', line 45

def settings
  {}
end