gpt4 book ai didi

ruby-on-rails - 为什么我的身份验证电子邮件不起作用?我得到一个 "AuthenticationError"

转载 作者:数据小太阳 更新时间:2023-10-29 07:23:02 26 4
gpt4 key购买 nike

每当我重设密码或尝试获取电子邮件确认时,我都会看到这种错误页面:

Net::SMTPAuthenticationError in Devise::PasswordsController#create

我在我的 Rails Server 日志中看到,看起来电子邮件正在发送,但是在它的底部你可以看到我收到了某种 500 错误。

这仅在我从开发发送电子邮件身份验证时发生(我在下面包含了我的 development.rb 文件)。似乎在 Heroku 上运行良好。

我已将我的电子邮件登录信息包含在一个单独的 .env 文件中,因此您不会在此处看到它,并且出于隐私考虑,我已在这些日志中更改了我的电子邮件地址。

感谢任何帮助!

Rails 服务器日志:

(0.9ms)  commit transaction
Rendered devise/mailer/confirmation_instructions.html.erb (1.1ms)

Sent mail to xx@xx.com (958.0ms)
Date: Wed, 23 Apr 2014 10:51:46 -0700
From: xx@xx.com
Reply-To: xx@xx.com
To: xx@xx.com
Message-ID: <5357fdb28f720_199810d2ab033cb@unknown20c9d07bac9b.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Welcome xx@xx.com!</p>

<p>You can confirm your account email through the link below:</p>

<p><a href="http://localhost:3000/users/confirmation?confirmation_token=ukG1PXbXyXP5LpjG1Eaa">Confirm my account</a></p>

Completed 500 Internal Server Error in 964ms

Net::SMTPAuthenticationError (530-5.5.1 Authentication Required. Learn more at
):
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/smtp.rb:948:in `check_response'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/smtp.rb:917:in `getok'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/smtp.rb:832:in `mailfrom'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/smtp.rb:659:in `send_message'
mail (2.5.4) lib/mail/network/delivery_methods/smtp.rb:113:in `block in deliver!'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/net/smtp.rb:520:in `start'
mail (2.5.4) lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!'
mail (2.5.4) lib/mail/message.rb:2129:in `do_delivery'
mail (2.5.4) lib/mail/message.rb:232:in `block in deliver'
actionmailer (4.0.0) lib/action_mailer/base.rb:456:in `block in deliver_mail'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
actionmailer (4.0.0) lib/action_mailer/base.rb:454:in `deliver_mail'
mail (2.5.4) lib/mail/message.rb:232:in `deliver'
devise (3.2.4) lib/devise/models/authenticatable.rb:173:in `send_devise_notification'
devise (3.2.4) lib/devise/models/confirmable.rb:102:in `send_confirmation_instructions'
devise (3.2.4) lib/devise/models/confirmable.rb:117:in `block in resend_confirmation_instructions'
devise (3.2.4) lib/devise/models/confirmable.rb:211:in `pending_any_confirmation'
devise (3.2.4) lib/devise/models/confirmable.rb:116:in `resend_confirmation_instructions'
devise (3.2.4) lib/devise/models/confirmable.rb:265:in `send_confirmation_instructions'
devise (3.2.4) app/controllers/devise/confirmations_controller.rb:9:in `create'
actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.0) lib/active_support/callbacks.rb:423:in `_run__3176473197347058618__process_action__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.0) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.0) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.0) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/mapper.rb:44:in `call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.0) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in `_run__455108311755261639__call__callbacks'
activesupport (4.0.0) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0) 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.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in `call'
railties (4.0.0) lib/rails/engine.rb:511:in `call'
railties (4.0.0) lib/rails/application.rb:97: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'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'


Rendered /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.9ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.1ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.9ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p392/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (16.0ms)

开发.rb :

Yoshirt::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.

# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

# Do not eager load code on boot.
config.eager_load = false

# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false

# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false

# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true

# Defining default url options for devise
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

# Change to true to allow email to be sent during development
# http://stackoverflow.com/questions/21610815/how-to-config-devise-gem-to-send-email-to-the-resource
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: "smtp.gmail.com",
port: 587,
domain: "mail.google.com",####important
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"]
}

end

最佳答案

根据与 OP 的聊天 session ,GMAIL_USERNAMEGMAIL_PASSWORD未从 .env 中提取这导致了这个错误。

硬编码user_namepassworddevelopment.rb完美运行。

我强烈建议您选择 figaro gem,这是安全配置 Rails 应用程序的绝佳方式。

此外,请阅读Daniel Kehoe 和Taylor Mock Rails Environment Variables 上发表的这篇优秀文章 。您还将了解到如何在您的应用程序中使用 figaro gem。

关于ruby-on-rails - 为什么我的身份验证电子邮件不起作用?我得到一个 "AuthenticationError",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23251943/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com