[英]Cannot send emails using AWS SES and Rails' Action Mailer without IAM Policy settings for all domains
我想使用 AWS SES 通過 Ruby on Rails (v6) 中的 Action Mailer 發送電子郵件。 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
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"
}
]
}
但是當工作人員發送電子郵件時,我收到了如下錯誤。
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'
我認為 SDK 默認會驗證是否所有域都具有可發送權限,但我找不到指定目標域。 我應該怎么辦?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.