Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

devise forgot password not working

I am using devise for authentication on rails 3. Signin, signout, signup working fine but nothing happens in case of forgot password. When I click on forgot password link it takes me to http://localhost:3000/users/password/new link and there I get a form asking my email address and a send me reset password instructions button, But when I click on that button it takes me to http://localhost:3000/users/sign_in but I dont receive mail regarding reset Password.

On console I can see following :

Sent mail to [email protected] (968ms)
Date: Tue, 05 Jun 2012 13:14:22 +0530
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, and you can do this through the link below.</p>

<p><a href="http://localhost:3000/users/password/edit?reset_password_token=gUB8L9nWNikjVJpnhbDW">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>

but i see no mail in my inbox.

Following is the code of my config/initializer/devise.rb file :

Devise.setup do |config| 
config.mailer_sender = "[email protected]"  
config.mailer = "Devise::Mailer" 
require 'devise/orm/active_record' 
config.case_insensitive_keys = [ :email ] 
config.stretches = 10 
config.use_salt_as_remember_token = true 
config.reset_password_keys = [ :email ] 

This is development.rb file code :

Alumnicell::Application.configure do
  # Settings specified here will take precedence over those in config/application.rb

  # In the development environment your application's code is reloaded on
  # every request.  This slows down response time but is perfect for development
  # since you don't have to restart the webserver when you make code changes.
  config.cache_classes = false

  # Log error messages when you accidentally call methods on nil.
  config.whiny_nils = true

  # Show full error reports and disable caching
  config.consider_all_requests_local       = true
  config.action_view.debug_rjs             = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger
  config.active_support.deprecation = :log

  # Only use best-standards-support built into browsers
  config.action_dispatch.best_standards_support = :builtin
    config.action_mailer.default_url_options = { :host => 'localhost:3000' }
end

what changes should I do to make it working?

like image 827
NJF Avatar asked Jun 12 '26 00:06

NJF


1 Answers

Do you have a local mailer daemon installed? My best solution was to use the gmail smtp like this (use your settings):

In config/environments/development.rb :

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => 'mondomaine.com',
  :user_name            => '[email protected]',
  :password             => 'mypassword',
  :authentication       => 'plain',
  :enable_starttls_auto => true  }

and delete your line :

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

In production mode, you will have a local mailer server as postfix.

like image 104
Sebastien Avatar answered Jun 13 '26 13:06

Sebastien



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!