2012-06-05 6 views
2

Я использую устройство для аутентификации на рейках 3. Signin, signout, signup работает нормально, но ничего не происходит в случае забытого пароля. Когда я нажимаю ссылку на забытый пароль, мне требуется ссылка http://localhost:3000/users/password/new, и там я получаю форму, просящую мой адрес электронной почты и отправку инструкции по восстановлению пароля, но когда я нажимаю на эту кнопку, она принимает меня до http://localhost:3000/users/sign_in, но я не получаю почту относительно сбросить пароль.devise забыл пароль не работает

На консоли можно увидеть следующее:

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> 

, но я не вижу никакой почты в почтовом ящике.

Ниже приводится код моего конфигурационного файла/инициализатора/devise.rb:

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 ] 

Это development.rb код файла:

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 

какие изменения я должен сделать, чтобы сделать его работать ?

+0

ли вы проверить ваш спам? – Sebastien

+0

да, я проверил, также нет почты – NJF

+0

Является ли мое решение выше хорошего для вас? Лучший способ - использовать почтовый сервер. Вы можете установить его на локальном (очень скучно ...) или использовать его. – Sebastien

ответ

1

У вас установлен локальный почтовый демон? Мое лучшее решение заключается в использовании протокола SMTP в Gmail, как это (используйте параметры):

В конфигурации/сред/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 } 

и удалить строку:

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

В в режиме производства у вас будет локальный почтовый сервер в качестве постфикса.

+0

Я настоятельно рекомендую sendgrid, также. Добавление этого в приложение yaml также рекомендуется: https://gist.github.com/mrgenixus/94bb6e945563fc2c745d –

0

решается вопрос ... сделал некоторые изменения в моем файле development.rb следующим образом:

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
config.action_mailer.default_url_options = { :host => '[email protected]' } 

Вместо локального хоста: 3000, попробуйте дать ур имя учетной записи Gmail.

1

Существует и другой способ решить эту проблему путем создания файла «конфигурация/инициализатор/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 
}