我是学习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)
答案 0 :(得分:0)
您有基本文档来实现此here。电子邮件似乎已发送,因此我建议检查两件事:
config/environment.rb
),因为您需要具有类似于以下配置的内容。配置:
ActionMailer::Base.smtp_settings = {
:user_name => 'your_sendgrid_username',
:password => 'your_sendgrid_password',
:domain => 'yourdomain.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}