Class: Aws::ActionMailer::SES::Mailer

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

Overview

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

Configure a delivery method with:

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

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

config.action_mailer.delivery_method = :ses

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/mailer.rb', line 24

def initialize(options = {})
  @client = Aws::SES::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
# File 'lib/aws/action_mailer/ses/mailer.rb', line 30

def deliver!(message)
  params = {
    raw_message: { data: message.to_s },
    source: message.smtp_envelope_from, # defaults to From header
    destinations: message.smtp_envelope_to # defaults to destinations (To,Cc,Bcc)
  }
  @client.send_raw_email(params).tap do |response|
    message.header[:ses_message_id] = response.message_id
  end
end

#settingsHash

Returns:

  • (Hash)


42
43
44
# File 'lib/aws/action_mailer/ses/mailer.rb', line 42

def settings
  {}
end