【发布时间】:2014-12-09 17:32:10
【问题描述】:
我是学习 Ruby 的新手,目前正在学习构建我们的第一个应用程序的课程。我正在尝试设置一个用户帐户,用户在注册帐户时会收到一封确认电子邮件,但没有发送任何电子邮件。我设置了 SendGrid 并在 config/environments/development.rb 中设置了以下内容:
config.action_mailer.raise_delivery_errors = true
然后我检查了我的控制台以查看电子邮件是如何传递的。这是我收到的输出:
Devise::Mailer#confirmation_instructions: processed outbound mail in 6.6ms
Sent mail to [xxxxxxx@xxx.com] (2373.5ms)
Date: Tue, 09 Dec 2014 12:15:30 -0500
From: please-change-me-at-config-initializers-devise@example.com
Reply-To: please-change-me-at-config-initializers-devise@example.com
To: [xxxxxxx@xxx.com]
Message-ID: <54872e323970f_5ce3fd7e895315c203e2@Users-MacBook-Pro.local.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Welcome [xxxxxxx@xxx.com]!</p>
<p>You can confirm your account email through the link below:</p>
<p><a href="http://localhost:3000/users/confirmation?confirmation_token=-Gi_zVPoo3yMVnbsuTq3">Confirm my account</a></p>
(2.5ms) commit transaction
Redirected to http://localhost:3000/
Completed 302 Found in 2457ms (ActiveRecord: 3.5ms)
Started GET "/" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Processing by WelcomeController#index as HTML
Rendered welcome/index.html.erb within layouts/application (0.6ms)
Completed 200 OK in 76ms (Views: 75.9ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/button.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/affix.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/alert.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/collapse.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/carousel.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/scrollspy.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/tooltip.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/dropdown.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/tab.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/modal.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/popover.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/posts.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/welcome.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/bootstrap/transition.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
Started GET "/apple-touch-icon-precomposed.png" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
ActionController::RoutingError (No route matches [GET] "/apple-touch-icon-precomposed.png"):
actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.8) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.8) lib/rails/engine.rb:514:in `call'
railties (4.1.8) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/username/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/Users/username/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/Users/username/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.3ms)
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/routes/_route.html.erb (2.0ms)
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.6ms)
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (22.6ms)
Started GET "/apple-touch-icon.png" for 127.0.0.1 at 2014-12-09 12:15:32 -0500
ActionController::RoutingError (No route matches [GET] "/apple-touch-icon.png"):
actionpack (4.1.8) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.8) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.8) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.8) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.8) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.8) lib/action_dispatch/middleware/static.rb:84:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.8) lib/rails/engine.rb:514:in `call'
railties (4.1.8) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/username/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/Users/username/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/Users/username/.rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.0ms)
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/routes/_route.html.erb (2.7ms)
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/routes/_table.html.erb (1.0ms)
Rendered /Users/username/.rvm/gems/ruby-2.1.5/gems/actionpack-4.1.8/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (22.6ms)
【问题讨论】:
-
很高兴听到您正在学习 rails :)。您能否更新您的问题以包含您的 config/environments/development.rb 文件?请务必删除您的用户名和密码。
-
从日志看来,邮件已发送 - 您是否检查了请求是否已到达发送网格?也许它是在您的垃圾邮件文件夹中收到的?
-
你能评论一下实际的问题是什么吗? :)
标签: ruby email authentication sendgrid