简体   繁体   中英

Using Amazon SES & Devise

So I want devise to utilize amazon ses to send the "I forgot my password" emails to a user. I have followed all of the steps for setting up devise with Gmail and then tried to configure SES as the mailer in production.rb I am new with ruby and I am sure there is something I have done incorrectly with either my syntax or configuration.

Production.rb

    config.action_mailer.delivery_method = :smtp,
    config.action_mailer.smtp_settings = {
      :address => "email-smtp.us-west-2.amazonaws.com",
      :user_name =>  ENV['AWS_SMTP_USER'], # Your SMTP user here.
      :password => ENV['AWS_SMTP_PASSWORD'], # Your SMTP password here.
      :authentication => :login,
      :enable_starttls_auto => true
  }

I stored both AWS_SMTP_USER & AWS_SMTP_PASSWORD to the config using "$ Heroku Config"

Devise.rb

  config.mailer_sender = 'Admin@synapticecho.com'

I don't think I am missing anything else, but I haven't found anyone trying to use Devise & SES as the mailer. I'm just not sure what other pieces I might be missing and I didn't find the AWS documentation all that helpful for configuring SES to work with Devise.

I can post the github project if it helps.

In my case.

I got the following error.

  • Net::SMTPFatalError (554 Message rejected: Email address is not verified

but, just like you. I didn't know missing anything else.

try below setting.

config.action_mailer.default_url_options = { host: Rails.application.secrets.HOST }
config.after_initialize do
  config.action_mailer.perform_deliveries    = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    address:        Rails.application.secrets.ACTION_MAILER_ADDRESS,
    port:           Rails.application.secrets.ACTION_MAILER_PORT,
    domain:         Rails.application.secrets.ACTION_MAILER_DOMAIN,
    user_name:      Rails.application.secrets.ACTION_MAILER_USER_NAME,
    password:       Rails.application.secrets.ACTION_MAILER_PASSWORD,
    authentication: :login,
    ssl:            true,
    tls:            true,
    enable_starttls_auto: true
  }
end

It works, my env. That point is config.after_initialize . but, I don't know why need it.

  • Rails 4.1.4
  • Devise 3.2.4
  • AWS SES
  • In AWS EC2
  • Verified email's domain is 'gmail.com' ( I'll change it)

I fix the problem by adding the following line in production.rb.

ActionMailer::Base.default :from => 'my.verified.email.address'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM