Ruby on Rails
Monday, May 7, 2018
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 => "username@yahoo.com", :password => "password", :openssl_verify_mode => :ssl } class Emailer < ActionMailer::Base def test_email(email_address, email_body) mail(to: email_address, from: 'username@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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment