2
votes

I am facing issue with devise forgot password.I am not receiving any email though devise displays messsage that "you will receive an email with instructions about how to reset your password in a few minutes".

Ruby-1.9.3 Rails 3.2 devise 2.2.4

My environments/development.rb

config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"


ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:domain => '[email protected]',
:user_name => '[email protected]',
:password => 'abcde',
 }

My environment.rb ActionMailer::Base.delivery_method = :smtp

My intializers/devise.rb

config.mailer_sender = "[email protected]"

And development.log shows

Sent mail to [email protected] (3205ms)
Date: Wed, 26 Jun 2013 23:33:01 +1000
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 the    link below.</p>

<p><a href="http://localhost:3000/users/password     /edit?reset_password_token=zb1mZUEzxpymqE8qorDJ">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 3423ms (ActiveRecord: 0.0ms)
2
This issue is closely related to stackoverflow.com/questions/16422316/… - rails4sandeep
stackoverflow.com/questions/16422316/… This issue is closely related to this and fixed now - rails4sandeep

2 Answers

2
votes

As have been mentioned above in development mode mails aren't being send for real, if you're curious how that's obtained (and maybe want to override that behavior) look into the following file config/environments/development.rb:

  #don't send emails in development
  config.action_mailer.perform_deliveries = false

Of course it would be better to use some mailtrap but if you want to just quickly see mail in your mailbox just change that false to true and here it goes if you've got properly configured mailer of course.

Edit:

That's my config for gmail and it works, there is no domain param so probably it's making trouble:

config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :user_name            => '<login>',
      :password             => '<password>',
      :authentication       => 'plain',
      :enable_starttls_auto => true  }

Edit2: And don't forget to restart your server ;)

0
votes

In development with your configuration emails are not sent but are just visible in the logs. You can try and use a service such as: