【问题标题】:What causes a End Of File Error when Rails Mailer sends an email?Rails Mailer 发送电子邮件时导致文件结束错误的原因是什么?
【发布时间】:2013-10-10 06:57:11
【问题描述】:

使用 gmail 帐户作为“发送地址”开发的 Rails 3.2.8 应用程序。 当邮件发送工作时,我的 environment.rb 文件包含以下内容:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
   :address => "smtp.gmail.com",       
   :port =>  587,                         
   :domain => "gmail.com",              
   :authentication => :login,            
   :user_name => "accountname",         
   :password => "123456789"              
}

我在我的应用程序日志中收到此消息: EOFError(到达文件末尾): 当上面的代码改为如下所示:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
   :address => "mail.company.com",
   :port =>   25,   
   :domain => "company.com", 
   :authentication =>   :login,
   :user_name =>  "accountname", 
   :password => "123456789"
}

我可以告诉你我 - 能够向电子邮件地址发送手动电子邮件 并在使用 ThunderBird 等电子邮件客户端时看到它,因此我知道 accountname@company.com 正常运行。

我不明白文件结束错误是如何起作用的。 我也不知道如何让更多信息出现在日志中。

我期待阅读一些关于确定文件结束原因的建议。

Started POST "/sendInvites?locale=en&lot_id=18&user_id=17" for 99.99.99.99 at 2013-10-03 08:52:09 -0700
Processing by WaitingListsController#sendInvites as HTML
  Parameters: {"authenticity_token"=>"uwz/6pW1rLPXR4gU3m3OwCmU0O3DSJ/haNM2/ai+OR8=", "locale"=>"en", "lot_id"=>"18", "user_id"=>"17"}
=======>>>> Beginning Send Invitation Process <<<<=======
=======>>>> just before the  PassEmailer.requestApprovedWL IS called to send the invitation <<<<=======
>>>> Beginning ::: requestApprovedWL(user_info) <<<<=======
  Rendered pass_emailer/requestApprovedWL.erb (0.9ms)
>>>> at the end of ::: requestApprovedWL(user_info) <<<<=======
Completed 500 Internal Server Error in 1718ms

EOFError (end of file reached):
  app/controllers/waiting_lists_controller.rb:276:in `sendInvites'

【问题讨论】:

  • 在讨论错误时,请始终粘贴整个错误跟踪。请将整个错误添加到您的帖子中。
  • 当我没有在后台运行mailcatcher 时,我刚刚在开发中遇到了这个错误。有点莫名其妙。
  • 你不是唯一一个。很遗憾没有解决方案。

标签: ruby-on-rails email actionmailer


【解决方案1】:

对于仍然遇到此问题的任何人,“无论何时”似乎都默认为“生产”。它在开发或登台时使用您的生产变量(或寻找它们)。此外,根据文档,它不会加载 Rails 环境。

当您在开发或登台时,您必须手动让 schedule.rb 知道这一点。找到 File.expand_path 方法here 后,下面是我如何启动我的 schedule.rb 文件:

require File.expand_path(File.dirname(__FILE__) + "/environment")
set :environment, Rails.env 
set :output, Rails.root.join('log','cron.log')

这为您提供了 Rails 环境,并允许您设置日志记录路径。

【讨论】:

    猜你喜欢
    • 2015-10-18
    • 2013-05-21
    • 2019-10-29
    • 1970-01-01
    • 2011-04-15
    • 2015-08-23
    • 1970-01-01
    • 2015-07-25
    • 2017-07-05
    相关资源
    最近更新 更多