0

宝石'导轨','3.2.12'

宝石“设计”,“〜> 2.2.4”

红宝石:红宝石1.9.3dev(2011-09-23修订33323)[i686-linux]

我尝试了我在网络上可以找到的所有可能的替代/组合,但面临无法摆脱这个错误:Errno::ECONNREFUSED (Connection denied - connect(2)) on Heroku。

我在开发环境中使用了 sendgrid 凭据,它们正在工作并且邮件已成功发送。但是只有在 Heroku 上我遇到了错误。

我能够在端口 587 和 25 上成功 telnet 到 smtp.sendgrid.net。

请在下面找到我的配置/代码片段。

/config/settings.yml

      app_name: 'DemoApp'

      default_host: <%= ENV['DEFAULT_HOST'] %>

      # Mail settings.
      mail:
        address: <%= ENV['MAIL_ADDRESS'] %>
        port: <%= ENV['MAIL_PORT'] %>
        domain: <%= ENV['MAIL_DOMAIN'] %>
        user_name: <%= ENV['MAIL_USER_NAME'] %>
        password: <%= ENV['MAIL_PASSWORD'] %>

/config/production.rb

    .....
    .....
    .....
    # Settings is available as part of 'rails_config' gem
    config.action_mailer.default_url_options = { host: Settings.default_host }

    if Settings.try(:mail)
      config.action_mailer.smtp_settings = {
        address:              Settings.mail.try(:address),
        port:                 Settings.mail.try(:port),
        domain:               Settings.mail.try(:domain),
        user_name:            Settings.mail.try(:user_name),
        password:             Settings.mail.try(:password),
        authentication:       "plain",
        enable_starttls_auto: true
      }

      config.action_mailer.perform_deliveries = true
      config.action_mailer.raise_delivery_errors = true
      config.action_mailer.delivery_method = :smtp
    end

    .....
    .....

/config/initializers/devise.rb

    config.mailer_sender = Settings.try(:mail).try(:user_name)

Heroku 配置

          $ heroku config
          === APP Config Vars
          DATABASE_URL:              <DB_URL>
          DEFAULT_HOST:              app-demo.herokuapp.com
          HEROKU_POSTGRESQL_RED_URL: <DB_URL>
          MAIL_ADDRESS:              smtp.sendgrid.net
          MAIL_DOMAIN:               heroku.com
          MAIL_PASSWORD:             <SENDGRID_PASSWORD>
          MAIL_PORT:                 587
          MAIL_USER_NAME:            <SENDGRID_USER_NAME>
          SENDGRID_PASSWORD:         <SENDGRID_PASSWORD>
          SENDGRID_USERNAME:         <SENDGRID_USER_NAME>

Heroku 日志

    $ heroku logs -t

    2013-08-13T08:52:17.722266+00:00 app[web.1]: ==========DEVISE: app17470133@heroku.com
    ...
    ...
    ..

    2013-08-13T08:38:59.948734+00:00 app[web.1]:
    2013-08-13T08:38:59.948734+00:00 app[web.1]: Sent mail to <USER_EMAIL> (15ms)
    2013-08-13T08:38:59.950628+00:00 app[web.1]: Completed 500 Internal Server Error in 229ms
    2013-08-13T08:38:59.954292+00:00 app[web.1]:
    2013-08-13T08:38:59.954292+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:540:in `initialize'
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:540:in `open'
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:540:in `tcp_socket'
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:550:in `block in do_start'
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:549:in `do_start'
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:519:in `start'
    2013-08-13T08:38:59.954292+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/mail-2.4.4/lib/mail/message.rb:229:in `block in deliver'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:415:in `block in deliver_mail'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:413:in `deliver_mail'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/mail-2.4.4/lib/mail/message.rb:229:in `deliver'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/devise-2.2.6/lib/devise/models/authenticatable.rb:175:in `send_devise_notification'
    2013-08-13T08:38:59.954463+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/devise-2.2.6/lib/devise/models/confirmable.rb:147:in `send_on_create_confirmation_instructions'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:416:in `_run__41454324238886340__create__57294411159809650__callbacks'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/callbacks.rb:268:in `create'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/persistence.rb:348:in `create_or_update'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/callbacks.rb:264:in `block in create_or_update'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:403:in `_run__41454324238886340__save__57294411159809650__callbacks'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    2013-08-13T08:38:59.954623+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/callbacks.rb:264:in `create_or_update'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/persistence.rb:84:in `save'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/validations.rb:50:in `save'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/attribute_methods/dirty.rb:22:in `save'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/transactions.rb:259:in `block (2 levels) in save'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/transactions.rb:313:in `block in with_transaction_returning_status'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/transactions.rb:208:in `transaction'
    2013-08-13T08:38:59.955010+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/transactions.rb:311:in `with_transaction_returning_status'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/transactions.rb:259:in `block in save'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/transactions.rb:270:in `rollback_active_record_state!'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/transactions.rb:258:in `save'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/devise-2.2.6/app/controllers/devise/registrations_controller.rb:15:in `create'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:167:in `process_action'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal/rendering.rb:10:in `process_action'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:436:in `_run__153182135430758755__process_action__3441329268483705872__callbacks'
    2013-08-13T08:38:59.955157+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/abstract_controller/callbacks.rb:17:in `process_action'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal/rescue.rb:29:in `process_action'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
    2013-08-13T08:38:59.955444+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/abstract_controller/base.rb:121:in `process'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/abstract_controller/rendering.rb:45:in `process'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal.rb:203:in `dispatch'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_controller/metal.rb:246:in `block in action'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in `call'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:36:in `call'
    2013-08-13T08:38:59.955593+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/routing/mapper.rb:42:in `call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/routing/route_set.rb:601:in `call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
    2013-08-13T08:38:59.955882+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/conditionalget.rb:35:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/head.rb:14:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/flash.rb:242:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/cookies.rb:341:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/query_cache.rb:64:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
    2013-08-13T08:38:59.956030+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `_run__2319839898307092388__call__57294411159809650__callbacks'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:405:in `__run_callback'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/callbacks.rb:81:in `run_callbacks'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-3.2.12/lib/rails/rack/logger.rb:32:in `call_app'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-3.2.12/lib/rails/rack/logger.rb:16:in `block in call'
    2013-08-13T08:38:59.956315+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/tagged_logging.rb:22:in `tagged'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-3.2.12/lib/rails/rack/logger.rb:16:in `call'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/request_id.rb:22:in `call'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.12/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.12/lib/action_dispatch/middleware/static.rb:62:in `call'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:143:in `pass'
    2013-08-13T08:38:59.956460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:155:in `invalidate'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:71:in `call!'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-3.2.12/lib/rails/engine.rb:479:in `call'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-3.2.12/lib/rails/application.rb:223:in `call'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-3.2.12/lib/rails/rack/log_tailer.rb:17:in `call'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
    2013-08-13T08:38:59.956749+00:00 app[web.1]:   vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
    2013-08-13T08:38:59.956897+00:00 app[web.1]:
    2013-08-13T08:38:59.956897+00:00 app[web.1]:

谢谢,吉涅什

4

1 回答 1

1

以下是有效的解决方案:

将 ActionMailer SMTP 设置和 default_url_options 移至初始化文件:

/config/initializers/smtp.rb

    # Settings is available as part of 'rails_config' gem
    ActionMailer::Base.default_url_options = { host: Settings.default_host }

    if Settings.try(:mail)
      ActionMailer::Base.smtp_settings = {
        address:              Settings.mail.try(:address),
        port:                 Settings.mail.try(:port),
        domain:               Settings.mail.try(:domain),
        user_name:            Settings.mail.try(:user_name),
        password:             Settings.mail.try(:password),
        authentication:       :plain,
        enable_starttls_auto: true
      }
    end

在环境文件(config/development.rb、config/production.rb)中只保留了交付特定的配置:

配置/生产.rb

  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp

100 万吨感谢 @swift 在这里提供他的指导:https ://stackoverflow.com/a/11583287/936494

谢谢,

吉涅什

于 2013-08-13T12:30:40.900 回答