简体   繁体   中英

Getting Devise authentication to send the email for password retrieval

I'm testing Devise authentication for Rails on my local host and want to get it to send emails for password retrieval (ie the "forgot your password" link). Password retrieval is built into Devise, it's just a matter of configuring it properly to get the email to send.

In initializers/devise.rb, I put

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

but when I tried to test the "forgot your password" link on Devise authentication for rails I got the error message below. If I do need to add other information for the email to actually send, what do I need to add and where??

In users model, these are the modules that are being used devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable

--- error message --- Errno::ECONNREFUSED in Devise::PasswordsController#create Connection refused - connect(2) Rails.root: /Users/myname/Sites/rails3d Application Trace | Framework Trace | Full Trace 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

In addition to what TJ said above, I'd recommend looking at the MailCatcher gem for testing emails locally. I've been using it a few days now and it works great.

mailcatcher.me

Also if you want the email to be sent and not just logged make sure and enable delivery in your development.rb file as well:

  config.action_mailer.perform_deliveries = true

HAve you setup your mail settings in environments/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  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM