设计 - "forgot password" 函数 - 不接受用户名和密码

Devise - "forgot password" function - Username and Password not accepted

我正在尝试设置 devise 自带的 "forgot password" 功能。我正在使用 rails 5。它总是给我错误:“535-5.7.8 用户名和密码未被接受”(Net::SMTPAuthenticationError in Users::PasswordsController#create though.

我的代码如下所示:

在development.rb我补充说:

config.action_mailer.default_url_options = { host: 'localhost', port:3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.default :charset => "utf-8"

ActionMailer::Base.smtp_settings = {
 :address => "smtp.gmail.com",
 :port => 587,
 :authentication => :plain,
 :domain => 'gmail.com',
 :user_name => 'xyz@gmail.com',
 :password => 'abcde',
 }

在 config > initialisers > devise.rb 我添加了:

config.mailer_sender = "xyz@gmail.com"

在配置下 > environment.rb:

ActionMailer::Base.delivery_method = :smtp

我是不是遗漏了什么或者做错了什么?

还有一个问题:我需要link它到我的个人账户(即用真实电子邮件账户的详细信息替换user_name和密码),没有默认设计账户电子邮件是从哪里发送的,对吗?我只是想知道,因为这样我团队中的每个人都能看到我们正在使用的邮件帐户的密码,对吗?

如有任何建议,我们将不胜感激!提前致谢。

SMTPAuthenticationError是SMTP认证层的错误。

这意味着您尝试使用的任何 SMTP 服务都会报告某种身份验证问题。

我不使用 Gmail 作为我的 SMP,但是这个错误对我来说似乎很奇怪,因为它说 Username and Password not accepted,这与不正确的不同。

进一步的研究表明 Gmail 不再接受安全性较低的 SMTP 请求。

Google now doesn't accept login from less secure apps. So you need to go to https://myaccount.google.com/security scroll to the bottom and turn ON "Allow less secure apps: ON". Now when you add the SMTP details to "Send as" google will accept them. You need to do this for the email ID you are adding in your Send as section.

我认为这与您的 gmail 设置有关。如果您在使用 gmail 发送电子邮件时看到类似 Net::SMTPAuthenticationError 的错误,请访问您的 gmail 设置并启用安全性较低的应用程序:

"MyAccount" > "Sign-in & security" > "Connected apps & sites" > "Allow less secure apps"

转到您的 google 电子邮件帐户设置并更改此设置。并尝试超过 1 次。