我能够使用aws-ses gem成功发送电子邮件,但我想在发送电子邮件时添加配置集。下面是我的配置。帮助我添加配置集。
我正在使用的Gem
gem "aws-ses", git: "https://github.com/zebitex/aws-ses.git", ref: "78-sigv4-problem"
配置初始化/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
(您可以更新您的开发。Rb too for test)
config.action_mailer.delivery_method = :ses
您可以像平常一样发送邮件,例如:UserMailer.send_confirmation_email(user_id).deliver