问题描述
我能够使用 aws-ses gem 成功发送电子邮件,但我想在发送电子邮件时添加配置集。下面是我的配置。帮我添加配置集。
我正在使用的宝石
gem "aws-ses",git: "https://github.com/zebitex/aws-ses.git",ref: "78-sigv4-problem"
config/initializers/amazon_ses.rb
ActionMailer::Base.add_delivery_method :ses,AWS::SES::Base,access_key_id: "abc",secret_access_key: "pqr",signature_version: 4
感谢您的帮助
解决方法
您可以使用以下配置
# add these gems to Gemfile
gem 'aws-sdk-rails','>= 2.1.0'
gem 'aws-sdk-sesv2'
然后创建初始化文件:config/initializers/ses_aws.rb
creds = Aws::Credentials.new(aws_access_key_id,aws_secret_key)
Aws::Rails.add_action_mailer_delivery_method(
:ses,credentials: creds,region: 'ap-southeast-1' # or any region
)
更新配置文件config/environments/production.rb
(您也可以更新您的 development.rb 以进行测试)
config.action_mailer.delivery_method = :ses
您可以像往常一样发送电子邮件,例如:UserMailer.send_confirmation_email(user_id).deliver