aws/aws-sdk-rails

SES mail delivery stopped working

tsujigiri opened this issue ยท 3 comments

I'm having trouble sending mail through SES after updating Rails and aws-sdk-rails. Before the update:

Rails version: 5.2.4.3
aws-sdk-rails version: 1.0.1

config.action_mailer.delivery_method = :aws_sdk

after the update:

Rails version: 6.1.4
aws-sdk-rails version: 3.6.1

config.action_mailer.delivery_method = :ses

The app is running on EC2 via ElasticBeanstalk. The docs say, that without providing credentials, it takes them from the instance metadata. This seems to have worked fine before the update. Now I get an exception:

Errno::EADDRNOTAVAIL: Cannot assign requested address - connect(2) for "localhost" port 25

Which looks like it is trying to send mail via SMTP at localhost. Locally, I can send mail through SES, if I set the AWS_ACCESS_KEY and AWS_SECRET_ACCESS_KEY environment variables. So, I guess it is an issue with discovering the credentials on EC2. The app is running in a Docker container on Docker running on 64bit Amazon Linux 2/3.4.9, which I updated from 64bit Amazon Linux 2018.03 v2.17.1 running Docker 20.10.7-ce, just to make sure it's not some version incompatibility issue between the gem and the platform, but the issue persists. Any hints at how to debug this issue would be appreciated. ๐Ÿ™

Thanks for opening an issue. I don't think that error is related to upgrading the aws-sdk-rails. I've never seen that before. If there was an issue discovering credentials, SES would still be called and fail with a missing credentials error.

That same error is posted here: https://stackoverflow.com/questions/56220560/rails-5-2-and-sidekiq-5-errnoeaddrnotavail-cannot-assign-requested-address Are you also using sidekiq or a similar library?

@mullermp I think you are right. It looks like sidekiq is preferring APP_ENV over RAILS_ENV now (I updated sidekiq as well) and is running a non-existent environment (which means all defaults) and, hence, doesn't see the config for the delivery method either. ๐Ÿ™ˆ Thanks for the hint!