【问题标题】:Devise Mailer EOF 500 status error设计 Mailer EOF 500 状态错误
【发布时间】:2018-07-26 21:40:15
【问题描述】:

我是 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" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["email", "user@email.com"], ["LIMIT", 1]]
  User Load (0.8ms)  SELECT  "users".* FROM "users" WHERE "users"."reset_password_token" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["reset_password_token", "token"], ["LIMIT", 1]]
   (0.3ms)  BEGIN
  SQL (0.7ms)  UPDATE "users" SET "reset_password_token" = $1, "reset_password_sent_at" = $2, "updated_at" = $3 WHERE "users"."id" = $4  [["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 从未收到任何消息。

我有点困惑,我研究过的每一件事都表明我只需要这样做才能让它工作——如果我不需要的话,我不想玩设计控制器。

谢谢!

【问题讨论】:

    标签: ruby-on-rails devise actionmailer


    【解决方案1】:

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

    config.action_mailer.delivery_method = :smtp
    

    进入

    config.action_mailer.delivery_method = :test
    

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

    编辑:这是在development.rb 文件中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 2018-12-28
      • 2018-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多