Obtaining authentication to send email to find the password

I am testing Rails authentication on my localhost and want it to send emails to find the password (i.e. the "forgot password" link). Password recovery is built into Devise, it’s just a matter of properly setting up email for sending.

In the /devise.rb initializers, I put

config.mailer_sender = " i...@mydomain.com " 

but when I tried to check the "forgot password" link on "Authentication for rails", I received the error message below. If I need to add other information for sending by email, what do I need to add and where?

In the user model, these are modules that are used by devise: database_authenticatable ,: registered,: restored ,: remembered ,: trackable ,: validatable

--- error message --- Errno :: ECONNREFUSED in Devise :: PasswordsController # create Connection refused - connect (2) Rails.root: / Users / myname / Sites / rails3d Application tracing | Frame Track | Complete route Request Parameters: {"Utf8" => "βœ“", "Authenticity_token" => "8oO5vXqO4esl3ztn5yE7OkVxZe + Ju94jj76rbKR225I =", "User" => {"email" => "myemail ... @ gmail.com"} , "commit" => "Send me reset password instructions"} Show session dump Show env dump response Headers

+6
source share
2 answers

HYou configure your mail settings in /development.rb

  config.action_mailer.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :domain => 'domain.com', :user_name => ' email_address@domain.com ', :password => 'password', :authentication => :plain, :enable_starttls_auto => true } 
+3
source

In addition to what TJ said above, I would recommend looking at the MailCatcher mailbox for local email testing. I use it after a few days and it works great.

mailcatcher.me

Also, if you want the message to be sent, and not just registered, make sure that you also include delivery in the development.rb file:

  config.action_mailer.perform_deliveries = true 
+3
source

Source: https://habr.com/ru/post/903160/


All Articles