3
votes

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?

4
yes i checkd,der also no mailNJF
Is my solution above good for you? The best way is to use a mail server. You can install one on local (very boring...) or use one.Sebastien
sry bt no luck...m getting new error NoMethodError in Devise/passwordsController#create undefined method `ago' for nil:NilClassNJF
Try to check/add config.reset_password_within = 1.hour on your initializer devise.Sebastien
uncommented that line now above NoMethodError is gone but still i cant see any mail in my inboxNJF

4 Answers

1
votes

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.

1
votes

There is also another way to solve this problem is by creating a file "config/initializer/setup_mail.rb"

ActionMailer::Base.smtp_settings = {
    :address              => "smtp.gmail.com",
    :port                 => 587,
    :domain               => "googlemail.com",
    :user_name            => "[email protected]",
    :password             => "secret_password",
    :authentication       => "plain",
    :enable_starttls_auto => true
}
0
votes

solved the issue ...made some changes in my development.rb file as follows :

require 'tlsmail'    
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
config.action_mailer.delivery_method = :smtp

 config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:tls                  => true,
:domain             => 'gmail.com', #you can also use google.com
:authentication     => :plain,

:user_name => "[email protected]",
:password => "seceret_password"
}
-2
votes
config.action_mailer.default_url_options = { :host => '[email protected]' }

Instead of localhost:3000, try giving ur gmail account name.