Class: Aws::Rails::SesMailer
- Inherits:
-
Object
- Object
- Aws::Rails::SesMailer
- Defined in:
- lib/aws/rails/ses_mailer.rb
Overview
Provides a delivery method for ActionMailer that uses Amazon Simple Email Service.
Once you have an SES delivery method you can configure Rails to use this for ActionMailer in your environment configuration (e.g. RAILS_ROOT/config/environments/production.rb)
config.action_mailer.delivery_method = :ses
Uses the AWS SDK for Ruby’s credential provider chain when creating an SES client instance.
Instance Method Summary collapse
-
#deliver!(message) ⇒ Object
Rails expects this method to exist, and to handle a Mail::Message object correctly.
-
#initialize(options = {}) ⇒ SesMailer
constructor
A new instance of SesMailer.
-
#settings ⇒ Object
ActionMailer expects this method to be present and to return a hash.
Constructor Details
#initialize(options = {}) ⇒ SesMailer
Returns a new instance of SesMailer.
21 22 23 24 |
# File 'lib/aws/rails/ses_mailer.rb', line 21 def initialize( = {}) @client = SES::Client.new() @client.config.user_agent_frameworks << 'aws-sdk-rails' end |
Instance Method Details
#deliver!(message) ⇒ Object
Rails expects this method to exist, and to handle a Mail::Message object correctly. Called during mail delivery.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aws/rails/ses_mailer.rb', line 28 def deliver!() params = { raw_message: { data: .to_s }, source: .smtp_envelope_from, # defaults to From header destinations: .smtp_envelope_to # defaults to destinations (To,Cc,Bcc) } @client.send_raw_email(params).tap do |response| .header[:ses_message_id] = response. end end |
#settings ⇒ Object
ActionMailer expects this method to be present and to return a hash.
40 41 42 |
# File 'lib/aws/rails/ses_mailer.rb', line 40 def settings {} end |