class Aws::Rails::SesMailer
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.
Public Class Methods
new(options = {})
click to toggle source
@param [Hash] options Passes along initialization options to
[Aws::SES::Client.new](https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SES/Client.html#initialize-instance_method).
# File lib/aws/rails/ses_mailer.rb, line 21 def initialize(options = {}) @client = SES::Client.new(options) @client.config.user_agent_frameworks << 'aws-sdk-rails' end
Public Instance Methods
deliver!(message)
click to toggle source
Rails
expects this method to exist, and to handle a Mail::Message object correctly. Called during mail delivery.
# File lib/aws/rails/ses_mailer.rb, line 28 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
settings()
click to toggle source
ActionMailer expects this method to be present and to return a hash.
# File lib/aws/rails/ses_mailer.rb, line 40 def settings {} end