ruby - AWS SES Timeout -


i using rails 4.2, aws-ses gem , mailform gem. trying set aws ses in development , have added config/development.rb:

  # configure mail using aws ses   config.after_initialize     actionmailer::base.delivery_method = :amazon_ses     actionmailer::base.custom_amazon_ses_mailer = aws::ses::base.new(         :secret_access_key => env['aws_secret_access_key'],         :access_key_id => env['aws_secret_key_id'],         :server => 'email.eu-west-2.amazonaws.com'     )   end 

when attempt send emails console, getting timeout after 30 seconds. started write asking help, occurred me mailform may not derived actionmailer. sure enough, mailform::base has superclass object, configuring actionmailer pointless.

i changed these 2 lines configure mailform::base, still timeout. possible these 2 gems not compatible? otherwise, suggestions either resolve or troubleshoot appreciated.

as mentioned in question, mailform , aws-ses gems not compatible out of box. possible can made work took different route.

some keys setting aws-ses (code included below reference):

  1. aws set - aws start off in sandbox mode. need register of destination email addresses in ses console work. click on email addresses link list verified addresses , add more. also, need set aws iam credentials use gem. when this, make sure user has ses full access managed policy attached (on iam console).
  2. :server setting - aws operates in multiple regions ses account set in 1 of them. determine region, go aws console , click on ses. see region in url - me region=us-west-2. recommend setting initializer described in dan croak's excellent article. did dan recommended, except set delivery method :amazon-ses , added server configuration line.
  3. configuration - dan's article (mentioned above) explains how set delivery_method in environment configuration file. again, used :amazon-ses.
  4. once have aws configured , gem installed, can test setup in rails console. easier troubleshoot there in code base.
  5. somewhat unrelated, used dotenv gem manage environment settings. in nutshell, once install gem, can stick of environment settings in ~/.env , have access them in env throughout code.

/config/initializers/amazon-ses.rb

actionmailer::base.add_delivery_method :amazon_ses, aws::ses::base,   :access_key_id      => env['aws_secret_key_id'],   :secret_access_key  => env['aws_secret_access_key'],   :server             => 'email.us-west-2.amazonaws.com' 

/config/environments/development.rb (excerpts):

# configure mailer development test config.action_mailer.raise_delivery_errors = true  # configure mail using aws ses config.action_mailer.delivery_method = :amazon_ses  # configure url options host = 'www.example.com' config.action_mailer.default_url_options = { host: host } 

of course, make work in production, you'll need make these changes /config/environments/production.rb. you'll need make aws secret settings on production server. if using heroku:

$ heroku config:add aws_secret_key_id=12345xyz $ heroku config:add aws_secret_access_key=67890abc 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -