[英]Cannot send emails using AWS SES and Rails' Action Mailer without IAM Policy settings for all domains
I want to send emails using AWS SES via Action Mailer in Ruby on Rails (v6).我想使用 AWS SES 通过 Ruby on Rails (v6) 中的 Action Mailer 发送电子邮件。 AWS provides aws-sdk-rails
gem, and it makes to be easy to configure using SES, but I realized that it needs sendable permissions such as ses:SendEmail
to ALL domains in SES. AWS 提供了aws-sdk-rails
gem,它使得使用 SES 配置变得容易,但我意识到它需要可发送权限,例如ses:SendEmail
到 SES 中的所有域。
# config/initializers/aws-sdk.rb
Aws.config[:credentials] = Aws::Credentials.new(ENV["AWS_ACCESS_KEY_ID"], ENV["AWS_SECRET_ACCESS_KEY"])
Aws::Rails.add_action_mailer_delivery_method(:aws_sdk, region: "us-east-1")
Rails.application.config.action_mailer.delivery_method = :aws_sdk
# app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base
default from: "info@example.com"
end
An AWS IAM User has the following policy, which allows to send emails from only example.com
domain. AWS IAM 用户具有以下策略,仅允许从example.com
域发送电子邮件。
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ses:SendEmail",
"ses:SendRawEmail"
],
"Resource": [
"arn:aws:ses:us-east-1:xxxxxxxxxxxx:identity/example.com"
],
"Effect": "Allow"
}
]
}
But I got an error like the following when workers send emails.但是当工作人员发送电子邮件时,我收到了如下错误。
ERROR: Processor failed: User `arn:aws:iam::xxxxxxxxxxxx:user/my-group/my-iam-user' is not authorized to perform `ses:SendRawEmail' on resource `arn:aws:ses:us-east-1:xxxxxxxxxxxx:identity/other-domain.com'
I think the SDK verifies whether all domains have sendable permissions by default, but I couldn't find to specify a target domain.我认为 SDK 默认会验证是否所有域都具有可发送权限,但我找不到指定目标域。 What should I do?我应该怎么办?
This is caused as a result of the domain being in a sandbox account.这是由于域位于沙盒帐户中造成的。 Within the SES documentation the following states are identified:在SES 文档中,确定了以下状态:
To send emails to any email address you need to move your from domain(s) out of sandbox mode .要将电子邮件发送到任何 email 地址,您需要将您的域移出沙盒模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.