ruby 如何修复'535-5.7.8用户名和密码不接受,了解更多关于'错误在Devise邮件确认?

7dl7o3gd  于 2023-06-05  发布在  Ruby
关注(0)|答案(1)|浏览(131)

我是一个初学Rails的程序员。我将从一个问题开始:我正在使用Devise与用户一起工作,并尝试启用邮件确认。很不幸,它不起作用。如果可能的话,请帮帮忙!我的错误:
Net::SMTPAuthenticationError in Devise::ConfirmationsController#create 535-5.7.8不接受用户名和密码。了解更多信息
我的config/environments/developorment.rb:

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: "smtp.gmail.com",
  port: 587,
  authentication: "plain",
  enable_starttls_auto: true,
  user_name: "xyz@gmail.com",
  password: "xyz", 
  domain: "gmail.com",
  openssl_verify_mode: "none",
}

My config/initializers/device.rb

config.mailer_sender = "xxx@gmail.com"

config.mailer = 'Devise::Mailer'

我的服务器从配置开始:

=> Booting Puma
=> Rails 7.0.5 application starting in development
=> Run `bin/rails server --help` for more startup options
Puma starting in single mode...
* Puma version: 5.6.5 (ruby 3.2.0-p0) ("Birdie's Version")
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 6074
* Listening on http://127.0.0.1:3000
* Listening on http://[::1]:3000
Use Ctrl-C to stop

和文件中的错误(或它被称为什么):

net-smtp (0.3.3) lib/net/smtp.rb:1088:in `check_auth_response'
net-smtp (0.3.3) lib/net/smtp.rb:845:in `auth_plain'
net-smtp (0.3.3) lib/net/smtp.rb:837:in `public_send'
net-smtp (0.3.3) lib/net/smtp.rb:837:in `authenticate'
net-smtp (0.3.3) lib/net/smtp.rb:670:in `do_start'
net-smtp (0.3.3) lib/net/smtp.rb:611:in `start'
mail (2.8.1) lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
mail (2.8.1) lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
mail (2.8.1) lib/mail/message.rb:2145:in `do_delivery'
mail (2.8.1) lib/mail/message.rb:253:in `block in deliver'
actionmailer (7.0.5) lib/action_mailer/base.rb:588:in `block in deliver_mail'
activesupport (7.0.5) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.5) lib/active_support/notifications.rb:206:in `instrument'
actionmailer (7.0.5) lib/action_mailer/base.rb:586:in `deliver_mail'
mail (2.8.1) lib/mail/message.rb:253:in `deliver'
actionmailer (7.0.5) lib/action_mailer/message_delivery.rb:119:in `block in deliver_now'
actionmailer (7.0.5) lib/action_mailer/rescuable.rb:17:in `handle_exceptions'
actionmailer (7.0.5) lib/action_mailer/message_delivery.rb:118:in `deliver_now'
devise (4.9.2) lib/devise/models/authenticatable.rb:204:in `send_devise_notification'
devise (4.9.2) lib/devise/models/confirmable.rb:121:in `send_confirmation_instructions'
devise (4.9.2) lib/devise/models/confirmable.rb:136:in `block in resend_confirmation_instructions'
devise (4.9.2) lib/devise/models/confirmable.rb:239:in `pending_any_confirmation'
devise (4.9.2) lib/devise/models/confirmable.rb:135:in `resend_confirmation_instructions'
devise (4.9.2) lib/devise/models/confirmable.rb:321:in `send_confirmation_instructions'
devise (4.9.2) app/controllers/devise/confirmations_controller.rb:11:in `create'
actionpack (7.0.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (7.0.5) lib/abstract_controller/base.rb:215:in `process_action'
actionpack (7.0.5) lib/action_controller/metal/rendering.rb:165:in `process_action'
actionpack (7.0.5) lib/abstract_controller/callbacks.rb:234:in `block in process_action'
activesupport (7.0.5) lib/active_support/callbacks.rb:118:in `block in run_callbacks'
actiontext (7.0.5) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (7.0.5) lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'
activesupport (7.0.5) lib/active_support/callbacks.rb:127:in `instance_exec'
activesupport (7.0.5) lib/active_support/callbacks.rb:127:in `block in run_callbacks'
activesupport (7.0.5) lib/active_support/callbacks.rb:138:in `run_callbacks'
actionpack (7.0.5) lib/abstract_controller/callbacks.rb:233:in `process_action'
actionpack (7.0.5) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (7.0.5) lib/action_controller/metal/instrumentation.rb:67:in `block in process_action'
activesupport (7.0.5) lib/active_support/notifications.rb:206:in `block in instrument'
activesupport (7.0.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (7.0.5) lib/active_support/notifications.rb:206:in `instrument'
actionpack (7.0.5) lib/action_controller/metal/instrumentation.rb:66:in `process_action'
actionpack (7.0.5) lib/action_controller/metal/params_wrapper.rb:259:in `process_action'
activerecord (7.0.5) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (7.0.5) lib/abstract_controller/base.rb:151:in `process'
actionview (7.0.5) lib/action_view/rendering.rb:39:in `process'
actionpack (7.0.5) lib/action_controller/metal.rb:188:in `dispatch'
actionpack (7.0.5) lib/action_controller/metal.rb:251:in `dispatch'
actionpack (7.0.5) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (7.0.5) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (7.0.5) lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
actionpack (7.0.5) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (7.0.5) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (7.0.5) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (7.0.5) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (7.0.5) lib/action_dispatch/routing/route_set.rb:852:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.7) lib/rack/etag.rb:27:in `call'
rack (2.2.7) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.7) lib/rack/head.rb:12:in `call'
actionpack (7.0.5) lib/action_dispatch/http/permissions_policy.rb:38:in `call'
actionpack (7.0.5) lib/action_dispatch/http/content_security_policy.rb:36:in `call'
rack (2.2.7) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.7) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/cookies.rb:704:in `call'
activerecord (7.0.5) lib/active_record/migration.rb:603:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (7.0.5) lib/active_support/callbacks.rb:99:in `run_callbacks'
actionpack (7.0.5) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/debug_exceptions.rb:28:in `call'
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.2.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/show_exceptions.rb:26:in `call'
railties (7.0.5) lib/rails/rack/logger.rb:40:in `call_app'
railties (7.0.5) lib/rails/rack/logger.rb:25:in `block in call'
activesupport (7.0.5) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (7.0.5) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (7.0.5) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (7.0.5) lib/rails/rack/logger.rb:25:in `call'
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/remote_ip.rb:93:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.7) lib/rack/method_override.rb:24:in `call'
rack (2.2.7) lib/rack/runtime.rb:22:in `call'
activesupport (7.0.5) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/server_timing.rb:61:in `block in call'
actionpack (7.0.5) lib/action_dispatch/middleware/server_timing.rb:26:in `collect_events'
actionpack (7.0.5) lib/action_dispatch/middleware/server_timing.rb:60:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/static.rb:23:in `call'
rack (2.2.7) lib/rack/sendfile.rb:110:in `call'
actionpack (7.0.5) lib/action_dispatch/middleware/host_authorization.rb:137:in `call'
railties (7.0.5) lib/rails/engine.rb:530:in `call'
puma (5.6.5) lib/puma/configuration.rb:252:in `call'
puma (5.6.5) lib/puma/request.rb:77:in `block in handle_request'
puma (5.6.5) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
puma (5.6.5) lib/puma/request.rb:76:in `handle_request'
puma (5.6.5) lib/puma/server.rb:443:in `process_client'
puma (5.6.5) lib/puma/thread_pool.rb:147:in `block in spawn_thread'

消息显示在终端中。是的,我知道这很重要,电子邮件是存在的,数据是从中获取的。
我尝试了许多选项,包括我最终得到的代码部分。什么都没用。

rseugnpd

rseugnpd1#

这与ActionMailer配置有关,而与Devise无关。从documentation身份验证应设置为以下:plain:login:cram_md5之一
以下是从上面链接的文档中的相关部分摘录的,并且是可用选项及其功能的解释,因此这完全取决于您希望使用的邮件服务器,但是您可以看到SSL不在可用选项之列
:authentication -如果您的邮件服务器需要身份验证,则需要在此处指定身份验证类型。这是一个符号,并且是以下之一:plain(将以明文发送密码),:login(将发送Base64编码的密码)或:cram_md5(结合Challenge/Response机制来交换信息和加密Message Digest 5算法来散列重要信息)
按照要求,典型的gmail配置将像这样使用SMTP

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'example.com',
  user_name:            '<username>',
  password:             '<password>',
  authentication:       'plain',
  enable_starttls_auto: true,
  open_timeout:         5,
  read_timeout:         5 }

来自rails action mailer documentation section 5.2
请务必更换用户名x的和密码x的与您的凭据和永远不要张贴您的凭据任何地方公开,我建议您修改您的密码对您的谷歌帐户立即,我已经编辑了您的问题,以隐藏您的密码,但它仍然可以查看由那些具有正确的特权

相关问题