Devise Mailer EOF 500 状态错误

Devise Mailer EOF 500 status error

我是 ActionMailer 的新手,但我也阅读了有关它的文档。我只是不确定 Devise 如何处理它。我正在使用 Rails 5.1,但我无法让 Devise 邮件程序在开发中工作。

在开发中尝试获取重设密码电子邮件时出现以下错误:

EOFError in Devise::PasswordsController#create
{"utf8"=>"✓",
 "authenticity_token"=>"token info",
 "user"=>{"email"=>"user@email.com"},
 "commit"=>"Send me reset password instructions"}

在服务器日志中:

Started POST "/users/password" for 127.0.0.1 at 2018-07-26 17:18:09 -0400
Processing by Devise::PasswordsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"token", "user"=>{"email"=>"user@email.com"}, "commit"=>"Send me reset password instructions"}
  User Load (1.3ms)  SELECT  "users".* FROM "users" WHERE "users"."email" =  ORDER BY "users"."id" ASC LIMIT   [["email", "user@email.com"], ["LIMIT", 1]]
  User Load (0.8ms)  SELECT  "users".* FROM "users" WHERE "users"."reset_password_token" =  ORDER BY "users"."id" ASC LIMIT   [["reset_password_token", "token"], ["LIMIT", 1]]
   (0.3ms)  BEGIN
  SQL (0.7ms)  UPDATE "users" SET "reset_password_token" = , "reset_password_sent_at" = , "updated_at" =  WHERE "users"."id" =   [["reset_password_token", "token"], ["reset_password_sent_at", "2018-07-26 21:18:10.075033"], ["updated_at", "2018-07-26 21:18:10.076032"], ["id", 2]]
   (2.6ms)  COMMIT
  Rendering devise/mailer/reset_password_instructions.html.erb
  Rendered devise/mailer/reset_password_instructions.html.erb (1.1ms)
Devise::Mailer#reset_password_instructions: processed outbound mail in 452.1ms

Sent mail to user@email.com (30027.6ms)
Date: Thu, 26 Jul 2018 17:18:11 -0400
To: user@email.com
Message-ID: <my system>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8

... the view...

Completed 500 Internal Server Error in 31449ms (ActiveRecord: 5.6ms)

EOFError (end of file reached):

我已经设置好我的 config/environments/development.rb:

  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp

  # Using MailCatcher server -- running @ 1080
  config.action_mailer.smtp_settings = { address: "localhost", port: 1080 }

我有 MailCatcher 服务器 运行。当我设置 'raise_deliver_errors' = false 时,我收到一条消息,提示消息已发送,但 MailCatcher 从未收到任何东西。

我有点困惑,我研究过的每一件事都说我只需要这样做就可以让它工作——如果不需要的话,我不想玩 Devise Controllers .

谢谢!

我所做的只是把这行代码从

config.action_mailer.delivery_method = :smtp

进入

config.action_mailer.delivery_method = :test

视图出现在日志中,当我在生产环境中配置 Sendgrid 时,电子邮件已正确发送。

编辑:这在 development.rb 文件中