我在 Controller 中的此代码上收到EOFError(文件结束错误)。该错误出现的块是在UserMailer.deliver_message(的行的末尾,我不知道如何解决此问题,我被困了大约2个月,建议您使用此站点。请帮忙。

  def contact
      @title= "Contact Us"
      if request.post?
       @message= Message.new(params[:contact])
        if @message.valid?
           UserMailer.deliver_message(
            :message => @message
            )
          flash[:notice] = "Thank you for contacting us"
          redirect_to contact_url
         end
        end
      end

这是消息文件:
<%= @message.name %> has sent feedback or a question:

  Message: <%= @message.body %>

  From: <%= @message.email %>

这是UserMailer
class UserMailer < ActionMailer::Base

  def message(mail)
    subject    'Feedback/Questions'
    recipients 'Email@email'
    from       'webmaster'
    body        mail
  end
end

好了,这是我得到的错误

PedalsController#contact中的EOFError

到达文件末尾

这是应用程序跟踪
/usr/lib64/ruby/1.8/net/protocol.rb:135:in `sysread'
/usr/lib64/ruby/1.8/net/protocol.rb:135:in `rbuf_fill'
/usr/lib64/ruby/1.8/timeout.rb:62:in `timeout'
/usr/lib64/ruby/1.8/timeout.rb:93:in `timeout'
/usr/lib64/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
/usr/lib64/ruby/1.8/net/protocol.rb:116:in `readuntil'
/usr/lib64/ruby/1.8/net/protocol.rb:126:in `readline'
/usr/lib64/ruby/1.8/net/smtp.rb:911:in `recv_response'
/usr/lib64/ruby/1.8/net/smtp.rb:897:in `getok'
/usr/lib64/ruby/1.8/net/smtp.rb:921:in `critical'
/usr/lib64/ruby/1.8/net/smtp.rb:895:in `getok'
/usr/lib64/ruby/1.8/net/smtp.rb:828:in `mailfrom'
/usr/lib64/ruby/1.8/net/smtp.rb:653:in `sendmail'
$HOME/blueflower/vendor/rails/actionmailer/lib/action_mailer/base.rb:684:in `perform_delivery_smtp'
/usr/lib64/ruby/1.8/net/smtp.rb:526:in `start'
$HOME/blueflower/vendor/rails/actionmailer/lib/action_mailer/base.rb:682:in `perform_delivery_smtp'
$HOME/blueflower/vendor/rails/actionmailer/lib/action_mailer/base.rb:523:in `__send__'
$HOME/blueflower/vendor/rails/actionmailer/lib/action_mailer/base.rb:523:in `deliver!'
$HOME/blueflower/vendor/rails/actionmailer/lib/action_mailer/base.rb:395:in `method_missing'
$HOME/blueflower/app/controllers/pedals_controller.rb:36:in `contact'

也许我缺少真正愚蠢的东西,但是如果有人可以回答这个问题,那将是惊人的。另外,我的解决办法是什么?

最佳答案

如果SMTP服务器关闭,也会发生这种情况。 (我使用了一个名为Sendgrid的第三方邮件,这种情况在它完全崩溃时发生了一次)

08-16 00:07