Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用designe发送重置密码指令_Ruby On Rails_Ruby_Devise - Fatal编程技术网

Ruby on rails 使用designe发送重置密码指令

Ruby on rails 使用designe发送重置密码指令,ruby-on-rails,ruby,devise,Ruby On Rails,Ruby,Devise,我正在尝试使用Desive with Rails发送重置密码指令。用户单击“忘记密码链接”,然后输入其电子邮件地址以接收重置密码说明。我看到电子邮件在开发日志中发送,但我没有收到我的测试电子邮件,我看到下面的错误。你知道我做错了什么吗 Timeout::Error - execution expired 在user_mailer.rb中,我有以下内容: class UserMailer < ActionMailer::Base include Devise::Mailers::Help

我正在尝试使用Desive with Rails发送重置密码指令。用户单击“忘记密码链接”,然后输入其电子邮件地址以接收重置密码说明。我看到电子邮件在开发日志中发送,但我没有收到我的测试电子邮件,我看到下面的错误。你知道我做错了什么吗

Timeout::Error - execution expired
在user_mailer.rb中,我有以下内容:

class UserMailer < ActionMailer::Base
 include Devise::Mailers::Helpers

 default :from => ENV["EMAIL_ADDRESS"]

 def reset_password_instructions(record, opts={})
  mail(:to => record, :subject => "Reset Password Instructions")
 end

end
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
:address   => "smtp.mandrillapp.com",
:port      => 25,
:user_name => ENV["MANDRILL_USERNAME"],
:password  => ENV["MANDRILL_API_KEY"],
:enable_starttls_auto => true, # detects and uses STARTTLS
:authentication => 'login', # Mandrill supports 'plain' or 'login'
:domain => 'mydomain.com', # your domain to identify your server when connecting
}
def send_reset_password_instructions
 UserMailer.reset_password_instructions(self.email).deliver
end
在user.rb中,我有以下内容:

class UserMailer < ActionMailer::Base
 include Devise::Mailers::Helpers

 default :from => ENV["EMAIL_ADDRESS"]

 def reset_password_instructions(record, opts={})
  mail(:to => record, :subject => "Reset Password Instructions")
 end

end
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.delivery_method = :smtp
# change to true to allow email to be sent during development
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"

config.action_mailer.smtp_settings = {
:address   => "smtp.mandrillapp.com",
:port      => 25,
:user_name => ENV["MANDRILL_USERNAME"],
:password  => ENV["MANDRILL_API_KEY"],
:enable_starttls_auto => true, # detects and uses STARTTLS
:authentication => 'login', # Mandrill supports 'plain' or 'login'
:domain => 'mydomain.com', # your domain to identify your server when connecting
}
def send_reset_password_instructions
 UserMailer.reset_password_instructions(self.email).deliver
end
正如我上面提到的,我在日志中看到电子邮件在超时之前生成-下面是完整的堆栈跟踪:

Started GET "/users/password/new" for 127.0.0.1 at 2013-10-10 17:32:24 -0500
Processing by Devise::PasswordsController#new as HTML
Rendered devise/passwords/new.html.erb within layouts/application (3.7ms)
Rendered layouts/_navigation.html.erb (1.6ms)
Rendered layouts/_messages.html.erb (0.1ms)
Completed 200 OK in 101ms (Views: 100.6ms | ActiveRecord: 0.0ms)


Started POST "/users/password" for 127.0.0.1 at 2013-10-10 17:32:28 -0500
Processing by Devise::PasswordsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"CebAAlhJgxz1yDEi5BvsJ/dOdUpAHl08yrG1NCVgi/o=", "user"=>{"email"=>"me@gmail.com"}, "commit"=>"Continue"}
User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'me@gmail.com' LIMIT 1
Rendered user_mailer/reset_password_instructions.html.erb (0.1ms)

Sent mail to me@gmail.com (30018ms)
Date: Thu, 10 Oct 2013 17:32:28 -0500
From: info@mydomain.com
To: me@gmail.com
Message-ID: <52572afc78c10_e9e43ffb7d69b4ec31274@Patricks-MacBook-Air.local.mail>
Subject: Reset Password Instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Hello!</p>

<p>Someone has requested a link to change your password. You can do this through the link below.</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>

Completed 500 Internal Server Error in 30044ms

请点击以下链接:


您是否已成功使用Mandrill帐户发送电子邮件?我建议尝试在开发中发送邮件。如果这样做有效,您可以开始缩小配置中的问题范围。谢谢-我尝试了MailCatcher,虽然我没有通过电子邮件收到消息,但它显示消息已正确发送。有关于排除mandrill配置故障的想法吗?我已经有一段时间mailchimp可以很好地处理欢迎信息和向普通电子邮件活动添加用户,但还没有弄清楚事务性电子邮件。ThanksMailCatcher截获发送的邮件,并将其放在web界面中,这样您就不应该收到它。相反,您应该能够在浏览器中的127.0.0.1:1080处看到它。至于Mandrill,我相信您仍然需要在主机上设置postfix或其他smtp接口,如果您还没有这样做的话。这是一个相当普遍的问题,所以你应该能够谷歌的细节或您的操作系统设置。