ActionMailer: end of file reached (EOFError)

1,012 views
Skip to first unread message

krfg

unread,
May 7, 2018, 3:19:35 AM5/7/18
to Ruby on Rails: Talk

I am studying Peter Cooper's book Beginning Ruby.
According to the author ActionMailer can be used independently of Rails.
So I installed the ActionMailer gem in a dedicated gemset and wrote the code below which is an extract from the book:



require 'action_mailer' ActionMailer::Base.smtp_settings = { :address => "smtp.mail.yahoo.com", :port => 465, :authentication => :login, :user_name => "user...@yahoo.com", :password => "password", :openssl_verify_mode => :ssl } class Emailer < ActionMailer::Base def test_email(email_address, email_body) mail(to: email_address, from: 'user...@yahoo.com', subject: 'action mailer test', body: email_body) end end Emailer.test_email('user...@gmail.com', 'This is a test e-mail!').deliver_now


When I run the rb file containing the above code I receive a long traceback (21 lines) with the following error message:

/home/krfg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/net/protocol.rb:189:in `rbuf_fill': end of file reached (EOFError)


Why do I receive this error?
Also I tried run test_email on an instance of the class Emailer but I receive
undefined method `deliver_now' for #<Mail::Message:0x0000000002256b68>
 

David Merrick

unread,
May 7, 2018, 4:37:36 AM5/7/18
to rubyonra...@googlegroups.com
EOF usually mean you reached the end of the file or are to read past it.

On Mon, May 7, 2018 at 7:19 PM, 'krfg' via Ruby on Rails: Talk <rubyonra...@googlegroups.com> wrote:

I am studying Peter Cooper's book Beginning Ruby.
According to the author ActionMailer can be used independently of Rails.
So I installed the ActionMailer gem in a dedicated gemset and wrote the code below which is an extract from the book:


require 'action_mailer'

ActionMailer::Base.smtp_settings = {
    :address => "smtp.mail.yahoo.com",
    :port => 465,
    :authentication => :login,
    :user_name => "user...@yahoo.com",
    :password => "password",
    :openssl_verify_mode => :ssl
}

class Emailer < ActionMailer::Base
  def test_email(email_address, email_body)
    mail(to: email_address, from: 'user...@yahoo.com
', subject: 'action mailer test', body: email_body)
  end
end

Emailer.test_email('username@gmail.com', 'This is a test e-mail!').deliver_now


When I run the rb file containing the above code I receive a long traceback (21 lines) with the following error message:

/home/krfg/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/net/protocol.rb:189:in `rbuf_fill': end of file reached (EOFError)


Why do I receive this error?
Also I tried run test_email on an instance of the class Emailer but I receive
undefined method `deliver_now' for #<Mail::Message:0x0000000002256b68>
 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c03a598c-c38b-4c1c-9385-aa824bf7f304%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Dave Merrick

Daves Web Designs

Website http://www.daveswebdesigns.co.nz/

Email merri...@gmail.com

Ph   03 216 2053

Cell 027 3089 169

krfg

unread,
May 8, 2018, 3:16:45 AM5/8/18
to Ruby on Rails: Talk


On Monday, May 7, 2018 at 10:37:36 AM UTC+2, David Merrick wrote:
EOF usually mean you reached the end of the file or are to read past it.

So why my code produces this error message?
I checked all the required ends: there are two, one for class Emailer and one for method test_email

krfg

unread,
May 11, 2018, 6:18:13 AM5/11/18
to Ruby on Rails: Talk
Reply all
Reply to author
Forward
0 new messages