4
我想發送重置密碼指令使用設計與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
我在開發測試,所以我development.rb有以下幾點:
# 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
}
,並在用戶。 rb,我有以下內容:
def send_reset_password_instructions
UserMailer.reset_password_instructions(self.email).deliver
end
正如我上面提到的,我看到的電子郵件在登錄前右超時正在生成 - 下面是完整的堆棧跟蹤:
Started GET "https://stackoverflow.com/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 "https://stackoverflow.com/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"=>"[email protected]"}, "commit"=>"Continue"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
Rendered user_mailer/reset_password_instructions.html.erb (0.1ms)
Sent mail to [email protected] (30018ms)
Date: Thu, 10 Oct 2013 17:32:28 -0500
From: [email protected]
To: [email protected]
Message-ID: <[email protected]ail>
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](http://mailcatcher.me/)發送郵件。如果可行,您可以開始縮小配置中問題的位置。 –
謝謝 - 我試過MailCatcher,它顯示郵件正確發送(雖然我沒有收到它通過電子郵件)。有關解決mandrill配置問題的任何想法?我已經讓mailchimp在一段時間內運行良好,歡迎郵件,並將用戶添加到一般電子郵件活動中,但還沒有弄清楚交易電子郵件。謝謝 – pvskisteak5
MailCatcher攔截外發郵件並使其在Web界面中可用,因此您不應該收到它。相反,您應該能夠在瀏覽器中的127.0.0.1:1080處看到它。至於Mandrill,我相信你仍然需要在你的主機上設置postfix或其他一些smtp接口,如果你還沒有這樣做的話。這是一個相當常見的問題,所以你應該能夠谷歌的細節或您的操作系統設置。 –