32

I am getting an EOFError (End Of File Error) on this code in my controller. The block where the error appears is at the end of the line that says UserMailer.deliver_message( I am unaware as to how to fix this, I have been stuck for about 2 months and this site was suggested. Please help.

  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

Here is the message file:

<%= @message.name %> has sent feedback or a question:

  Message: <%= @message.body %>

  From: <%= @message.email %>

And here is the UserMailer

class UserMailer < ActionMailer::Base

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

Alright here is the error I get


EOFError in PedalsController#contact

end of file reached


and here is the application trace


/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'

Maybe I am missing something really stupid, but if someone can answer this, that would be amazing. Also, what is my fix?

Deadder
  • 535
  • 1
  • 4
  • 16
  • 1
    Please edit your question to include the code from your `Message` model and your `UserMailer`. – John Topley Jun 14 '10 at 16:26
  • 1
    Seems like the mailer has problems with your e-mail delivery. Can you post the full error, including stack trace and your e-mail configuration? – molf Jun 15 '10 at 11:38

5 Answers5

17

This can also happen if the SMTP server is down. (I use a 3rd party mailer called Sendgrid and this happened once when it goes down entirely)

lulalala
  • 17,572
  • 15
  • 110
  • 169
12

If you are using "ZOHO" to send email,

one of the reason I had a problem with this was.

  1. You should use a valid from value. In my case, I used a non existing email account default from: "info@luxelectrical.net.au" hence zoho server is not allowing the email to be sent which causes EOF Error.
  2. You should allow IMAP settings on ZOHO IMAP SETTING FOR ZOHO
Emil Reña Enriquez
  • 2,929
  • 1
  • 29
  • 32
  • More specific to "valid from value" - it needs to be a from-address from the account connected to the user/pass you are using to send via Zoho. A different Zoho address, even using your same domain, which has different login-credentials, you still get the crazy EOF error (which makes no sense). – JosephK Aug 30 '17 at 15:34
3

Alright, thank you guys, I actually had malformed code in the UserMailer. The actual code I had in the from line had a <> encasing an email address and had the senders name on the outside. Though that has worked on some of the private email servers I have used/work on, it does not work on Hostmonster. Soo, for anyone that ends up using Hostmonster in the future, keep everything about your mailers configuration simple (the message can be complicated but the SMTP Config needs to be simple). Thanks.

Deadder
  • 535
  • 1
  • 4
  • 16
1

Do you have to authenticate to the mail server?

:authentication => :plain (if so), :enable_starttls_auto => true

0

It's a problem with your SMTP.

The mailer connect by SMTP to him and can't close corretly the socket.

shingara
  • 46,608
  • 11
  • 99
  • 105