SES SDK Rails6 not picking up Region

131 Views Asked by At

Update:

I turned on

  config.action_mailer.raise_delivery_errors = true

Which resulted in reported error about the region being used - which is not the one I configured.

The following identities failed the check in region US-EAST-1

However per below my configured AWS_REGION is ap-southeast-2 (which should be valid for SES).

--

I have set up my rails6 app to deliver email via SES but when I send an email my logs report it delivered, but it is not received at the To: address and no errors are reported. The email also does not appear in the console statistics.

Delivered mail [email protected] (1334.3ms)

I have authorised/verified my domain and email address and a test email composed in the AWS console successfully sends.

I've set up my environment variables using Figaro and loaded using an initialiser:

Rails.application.reloader.to_prepare do
    ActionMailer::Base.add_delivery_method :ses, AWS::SES::Base,
      access_key_id: ENV['AMAZON_ACCESS_ID'],
      secret_access_key: ENV['AMAZON_SECRET_KEY'],
    region: ENV['AWS_REGION']
end

My region is ap-southeast-2 which supports SES.

I've just updated the gem but problem remains:

gem 'aws-ses', '~> 0.7.1', require: 'aws/ses'

So in the absence of error messages and nothing visible in the console I'm at a loss as to what to try next...

Thanks in advance.

1

There are 1 best solutions below

0
On

Okay so progress:

I added this configuration per the SDK documentation:

server: "email." + ENV['AWS_REGION'] + ".amazonaws.com",
message_id_domain: ENV['AWS_REGION'] + ".amazonses.com"

However I then got a credentials error.

After this I got so frustrated I just reverted SES to use the default region for SES which is us-east-1, and removed the additional configuration parameters and it now works just fine.

So I'm not happy that I have to use a different region from everything else but now at least I can send email.