Devise - 设置邮件程序
我已将设计实施到 Rails 3 应用程序中。我正在尝试让邮件程序与设备一起使用。我目前的情况是,当我输入一个电子邮件地址时,这是我设置的默认 Gmail 帐户。它将我重定向回“登录”页面,并给我一个通知“说我很快就会收到说明”,但这些说明并未发送。我和在 RubyForum 上发帖的人有同样的问题,我读了这篇文章,但没有根本没有帮助。我的 config/environment/development.rb 如下所示:
Project::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
#SMTP
config.action_mailer.default_url_options = { :host => 'localhost' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => '[email protected]',
:password => '',
:authentication => 'plain',
:enable_starttls_auto => true }
end
我缺少什么吗?
当我重定向回登录页面时,我进入控制台:
Sent mail to [email protected] (30181ms)
Date: Thu, 15 Sep 2011 14:48:06 +0100
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/users/password/edit?reset_password_token=fqJXk6JbotIxIv3Awq1s">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://0.0.0.0:3000/login
Completed 302 Found in 32658ms
Started GET "/login" for 127.0.0.1 at 2011-09-15 14:48:36 +0100
Processing by Devise::SessionsController#new as HTML
SQL (0.7ms) describe `roles_users`
SQL (0.9ms) describe `roles_users`
Rendered layouts/_stylesheets.html.erb (0.9ms)
Rendered layouts/_javascripts.html.erb (1.6ms)
Rendered layouts/_header.html.erb (0.8ms)
Rendered layouts/_logo.html.erb (0.7ms)
Rendered layouts/_errors.html.erb (1.8ms)
Rendered devise/sessions/new.html.erb within layouts/application (62.0ms)
Completed 200 OK in 150ms (Views: 68.9ms | ActiveRecord: 1.6ms)
设计密码控制器
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
if successful_and_sane?(resource)
set_flash_message(:notice, :send_instructions) if is_navigational_format?
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
else
respond_with_navigational(resource){ render_with_scope :new }
end
end
I have devise implemented into a rails 3 application. I am trying to get the mailer to work with devise. My current situation is that when I enter an email address which is a default gmail account I have set up. It redirects me back to the 'login' page and gives me a notice 'saying I will recieve instructions soon' however these instructions are not being sent. I have the same problem as some one who posted on RubyForum I read this post and it didn't help at all. My config/environment/development.rb look like the following:
Project::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
#SMTP
config.action_mailer.default_url_options = { :host => 'localhost' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => '[email protected]',
:password => '',
:authentication => 'plain',
:enable_starttls_auto => true }
end
Is there something I am missing?
When I am redirected back to the login page I get in the console:
Sent mail to [email protected] (30181ms)
Date: Thu, 15 Sep 2011 14:48:06 +0100
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/users/password/edit?reset_password_token=fqJXk6JbotIxIv3Awq1s">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://0.0.0.0:3000/login
Completed 302 Found in 32658ms
Started GET "/login" for 127.0.0.1 at 2011-09-15 14:48:36 +0100
Processing by Devise::SessionsController#new as HTML
SQL (0.7ms) describe `roles_users`
SQL (0.9ms) describe `roles_users`
Rendered layouts/_stylesheets.html.erb (0.9ms)
Rendered layouts/_javascripts.html.erb (1.6ms)
Rendered layouts/_header.html.erb (0.8ms)
Rendered layouts/_logo.html.erb (0.7ms)
Rendered layouts/_errors.html.erb (1.8ms)
Rendered devise/sessions/new.html.erb within layouts/application (62.0ms)
Completed 200 OK in 150ms (Views: 68.9ms | ActiveRecord: 1.6ms)
Devise password_controller
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
if successful_and_sane?(resource)
set_flash_message(:notice, :send_instructions) if is_navigational_format?
respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
else
respond_with_navigational(resource){ render_with_scope :new }
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题如下:
更改
config/initializers/devise.rb
中的电子邮件信息Here's the issue:
Change the email info in
config/initializers/devise.rb