简体   繁体   English

设计 - “忘记密码”功能 - 不接受用户名和密码

[英]Devise - "forgot password" function - Username and Password not accepted

I am trying to set up the "forgot password" function that comes with devise.我正在尝试设置设计附带的“忘记密码”功能。 I am using rails 5. It always gives me the error: "535-5.7.8 Username and Password not accepted"(Net::SMTPAuthenticationError in Users::PasswordsController#create though.我正在使用 rails 5。它总是给我错误:“535-5.7.8 用户名和密码不被接受”(虽然用户::密码控制器中的 Net::SMTPAuthenticationError#create。

My code looks like this:我的代码如下所示:

In development.rb I added:在 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',
 }

Under config > initialisers > devise.rb I added:在 config > initialisers > devise.rb 下我添加了:

config.mailer_sender = "xyz@gmail.com"

and under config > environment.rb:在 config > environment.rb 下:

ActionMailer::Base.delivery_method = :smtp

Am I missing anything or did I do something wrong?我错过了什么还是我做错了什么?

Also another question: I need to link it to my personal account (ie replace the user_name and password with the details of a real email account), there is no default devise account the emails get sent from, right?还有另一个问题:我需要将它链接到我的个人帐户(即用真实电子邮件帐户的详细信息替换用户名和密码),没有发送电子邮件的默认设计帐户,对吗? I'm just wondering because like this everyone in my team would be able to see the password of the mail account we're using, right?我只是想知道,因为这样我团队中的每个人都可以看到我们正在使用的邮件帐户的密码,对吗?

Any advice would be highly appreciated!任何建议将不胜感激! Thanks in advance.提前致谢。

SMTPAuthenticationError is an error at the SMTP authentication layer. SMTPAuthenticationError是SMTP验证层的错误。

This means that whatever SMTP service you're trying to use is reporting back some kind of authentication issue. 这意味着您要使用的任何SMTP服务都将报告某种身份验证问题。

I do not use Gmail as my SMP, but this error seems strange to me as it says Username and Password not accepted , which is different from incorrect. 我没有将Gmail用作我的SMP,但是这个错误对我来说似乎很奇怪,因为它说Username and Password not accepted ,这与不正确不同。

Further research shows that Gmail no longer accepts less secure SMTP requests. 进一步的研究表明,Gmail不再接受安全性较低的SMTP请求。

Google now doesn't accept login from less secure apps. Google现在不接受来自不太安全的应用程序的登录。 So you need to go to https://myaccount.google.com/security scroll to the bottom and turn ON "Allow less secure apps: ON". 因此,您需要转到https://myaccount.google.com/security滚动至底部,然后将“允许不太安全的应用程序:打开”打开。 Now when you add the SMTP details to "Send as" google will accept them. 现在,当您将SMTP详细信息添加到“发送为”时,Google会接受它们。 You need to do this for the email ID you are adding in your Send as section. 您需要对“发送为”部分中添加的电子邮件ID进行此操作。

I think it's related with your gmail settings. 我认为这与您的Gmail设置有关。 If you see errors like Net::SMTPAuthenticationError while using gmail for sending out emails, visit your gmail settings and enable less secure apps: 如果在使用gmail发送电子邮件时看到诸如Net::SMTPAuthenticationError类的错误,请访问gmail设置并启用安全性较低的应用:

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

Go to your google email account setting and change this settings.转到您的谷歌电子邮件帐户设置并更改此设置。 and try more than 1 times.并尝试超过 1 次。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM