M
M
Max2016-03-12 16:56:23
Ruby on Rails
Max, 2016-03-12 16:56:23

Why is the password recovery not sent to the mail (Devise)?

Hello, I connected and configured the Devise gem initially. But sending a message to the mail does not work when trying to recover the password.
application.rb code

ActionMailer::Base.smtp_settings = {
        :address        => 'smtp.gmail.com',
        :domain         => 'mail.google.com',
        :port           => 587,
        :user_name      => ENV['почта@gmail.com'],
        :password       => ENV['пароль'],
        :authentication => :login,
        :enable_starttls_auto => true
    }

Added 2 lines to development.rb
config.action_mailer.default_url_options = { :host => "localhost" }
  config.action_mailer.delivery_method = :smtp

When you try to send the page takes a long time to load and reload. The following code is in the console:
Devise::Mailer#reset_password_instructions: processed outbound mail in 212.1ms

Sent mail to [email protected] (30007.4ms)
Date: Sat, 12 Mar 2016 14:49:31 +0200
From: [email protected]
Reply-To: [email protected]
To: [email protected]
Message-ID: <[email protected]>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Hello [email protected]!</p>

<p>Someone has requested a link to change your password. You can do this through the link below.</p>

<p><a href="http://localhost/users/password/edit?reset_password_token=L3A6c7mtnPzWdxqfNs9L">Change my password</a></p>

<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>

Redirected to http://localhost:3000/users/sign_in
Completed 302 Found in 30475ms (ActiveRecord: 19.3ms)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Demidenko, 2016-03-12
@maxprof

  1. rails new EmailDevise
  2. Add to Gemfile gem 'devise'
  3. bundle install
  4. rails generate motto:install
  5. rails generate motto User
  6. rake db:create
  7. rake db:migrate
  8. Created a password for gmail app using this link
  9. In config/initializers/devise.rb put config.mailer_sender = 'your email'
  10. Add the following settings to config/environments/development.rb:
config.action_mailer.default_options = { from: 'твой email' }
  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,
      user_name:            'твой email',
      password:             'пароль созданный для gmail app',
      authentication:       'login',
      enable_starttls_auto: true
  }

E
Evgeny Danilov, 2016-03-12
@jmelkor

To send from localhost, you need to dance with a tambourine. Somewhere on the open spaces of stackoverflow even the question "what the hell is a button accordion for a goat?" Deploy and it should be ok... And so you got a letter in the console. Actually, what more do you need from development?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question