I''m having trouble getting ActionMailer to actually send anything. I keep getting EOFError and I can''t seem to find anything about it. Thanks, Shad environment.rb ==========# Include your app''s configuration here: ActionMailer::Base.server_settings = { :address => "smtp.liquidcultures.com", :port => 25, :domain => "www.liquidcultures.com", :user_name => "pogs-gU5ZryCuvN3Gps6F8TFhCtBPR1lH4CV8@public.gmane.org", :password => "my_password", :authentication => :plain } mailman.rb =======class Mailman < ActionMailer::Base def mail( email ) # Email header info MUST be added here @recipients = email @from = "ls-gU5ZryCuvN3Gps6F8TFhCtBPR1lH4CV8@public.gmane.org" @subject = "Thank you for registering with our website" # Email body substitutions go here @body["email"] = email puts "here" end end mail.rhtml ======<?xml version="1.0" encoding="utf-8"?> <html> <head> </head> <body id="" onload=""> hello, <%= @email %> </body> </html> I run the console and then try: >>Mailman.deliver_mail( "foo-/K3FCmxHHlvQT0dZR+AlfA@public.gmane.org") And get: EOFError: End of file reached from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:197:in `sysread'' from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:197:in `rbuf_fill'' from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:196:in `timeout'' from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/timeout.rb:55:in `timeout'' from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:196:in `rbuf_fill'' from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:160:in `readuntil'' (etc.)
just a guess, but you might want to try changing :authentication to :login instead of :plain. Shad Reynolds wrote:> I''m having trouble getting ActionMailer to actually send anything. I > keep getting EOFError and I can''t seem to find anything about it. > > Thanks, Shad > > environment.rb > ==========> # Include your app''s configuration here: > ActionMailer::Base.server_settings = { > :address => "smtp.liquidcultures.com", > :port => 25, > :domain => "www.liquidcultures.com", > :user_name => "pogs-gU5ZryCuvN3Gps6F8TFhCtBPR1lH4CV8@public.gmane.org", > :password => "my_password", > :authentication => :plain > } > > mailman.rb > =======> class Mailman < ActionMailer::Base > > def mail( email ) # Email header info MUST be added here > @recipients = email > @from = "ls-gU5ZryCuvN3Gps6F8TFhCtBPR1lH4CV8@public.gmane.org" > @subject = "Thank you for registering with our website" > > # Email body substitutions go here > @body["email"] = email > puts "here" > end > end > > mail.rhtml > ======> <?xml version="1.0" encoding="utf-8"?> > <html> > <head> > </head> > <body id="" onload=""> > hello, <%= @email %> > </body> > </html> > > > I run the console and then try: > >>Mailman.deliver_mail( "foo-/K3FCmxHHlvQT0dZR+AlfA@public.gmane.org") > > And get: > EOFError: End of file reached > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:197:in > `sysread'' > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:197:in > `rbuf_fill'' > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:196:in > `timeout'' > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/timeout.rb:55:in > `timeout'' > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:196:in > `rbuf_fill'' > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:160:in > `readuntil'' > (etc.)
Nope, that''s not it. Same result with :plain or :login. On 11/12/05, Lou Vanek <vanek-9H8CmIPm+GA@public.gmane.org> wrote:> just a guess, but you might want to try changing :authentication > to :login instead of :plain. > > > Shad Reynolds wrote: > > I''m having trouble getting ActionMailer to actually send anything. I > > keep getting EOFError and I can''t seem to find anything about it. > > > > Thanks, Shad > > > > environment.rb > > ==========> > # Include your app''s configuration here: > > ActionMailer::Base.server_settings = { > > :address => "smtp.liquidcultures.com", > > :port => 25, > > :domain => "www.liquidcultures.com", > > :user_name => "pogs-gU5ZryCuvN3Gps6F8TFhCtBPR1lH4CV8@public.gmane.org", > > :password => "my_password", > > :authentication => :plain > > } > > > > mailman.rb > > =======> > class Mailman < ActionMailer::Base > > > > def mail( email ) # Email header info MUST be added here > > @recipients = email > > @from = "ls-gU5ZryCuvN3Gps6F8TFhCtBPR1lH4CV8@public.gmane.org" > > @subject = "Thank you for registering with our website" > > > > # Email body substitutions go here > > @body["email"] = email > > puts "here" > > end > > end > > > > mail.rhtml > > ======> > <?xml version="1.0" encoding="utf-8"?> > > <html> > > <head> > > </head> > > <body id="" onload=""> > > hello, <%= @email %> > > </body> > > </html> > > > > > > I run the console and then try: > > >>Mailman.deliver_mail( "foo-/K3FCmxHHlvQT0dZR+AlfA@public.gmane.org") > > > > And get: > > EOFError: End of file reached > > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:197:in > > `sysread'' > > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:197:in > > `rbuf_fill'' > > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:196:in > > `timeout'' > > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/timeout.rb:55:in > > `timeout'' > > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:196:in > > `rbuf_fill'' > > from /Applications/Locomotive/Bundles/rails-0.14.1-min.bundle/Contents/Resources/ports/lib/ruby/1.8/net/protocol.rb:160:in > > `readuntil'' > > (etc.) > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://www.ShadReynolds.com http://www.flickr.com/photos/shadreynolds/
Have you tested your email w/o using activesupport? #!/bin/env ruby require ''net/smtp'' # Helper method. # Append _appendage_ to end of string if it already doesn''t exist # at the end of the string. class String #:nodoc: def appendIfMissing(appendage) return self if appendage.nil? || appendage.size < 1 return appendage if size < 1 if self[-appendage.size..-1] == appendage self else self + appendage end end end class String #:nodoc: def blank? empty? || strip.empty? end end # Print an error message. def err(msg, printRubyErr=false, fatal=true) #:nodoc: STDERR.print "\n### ERROR: #{msg}\n\n" STDERR.print "\n#{$!}\n\n" if printRubyErr exit if fatal "### ERROR: #{msg}\n#{$!}\n" end # simple check of email address. def checkMailAddress(address, descr) #:nodoc: address.strip! addr = address[/<?\w+@\w+\.\w+>?$/] if addr.blank? err(descr,false,false) return nil end addr end # Send email. def mail( od ) # The email is composed of the ''From'', ''To'', and ''Subject'' fields, followed by the body text. # Strip off leading white space. (msgstr = <<END_OF_MAIL_MESSAGE).gsub!(/^\s+/, '''') From: #{od[''-='']} To: #{od[''-t'']} Subject: #{od[''-j''].blank? ? ''No Subject'' : od[''-j'']} END_OF_MAIL_MESSAGE msgstr += od[''-b''] return if (addr_from = checkMailAddress(od[''-=''], "no ''From'' address (#{od[''-='']})") ).nil? return if (addr_to = checkMailAddress(od[''-t''], "no ''To'' address (#{od[''-t'']})") ).nil? # The email is actually sent here. begin Net::SMTP.start(od[''-m''], 25, od[''-n''], od[''-S''], od[''-P''], :login) { |smtp| smtp.send_message msgstr, addr_from, addr_to } puts "-- mail sent to #{addr_to}" if od[''-V''] rescue Exception => ex err("unable to send mail.\n#{msgstr}\n#{$!}\naddr from:#{addr_from}\naddr to:#{addr_to}", true) end end # mail od = { ''-='' => ''My Long Name<user-ND7put3rsLk@public.gmane.org>'', # mail from ''-t'' => ''My Long Name<user-ND7put3rsLk@public.gmane.org>'', # mail to ''-j'' => ''This is a test'', # mail subject ''-b'' => ''Body text of the email.'', # mail body text ''-m'' => ''smtp.XXX.net'', # mail server ''-n'' => ''www.XXX.net'', # domain sending mail from ''-S'' => ''mailusername'', # mail user name ''-P'' => ''super_secret_password'', # mail password ''-V'' => true } mail od __END__
I figured it out. Seems that my hosting company does not require authentication on SMTP. I commented out the username, password, authentication variables and everything works perfectly now. Thanks Lou! Shad On 11/12/05, Lou Vanek <vanek-9H8CmIPm+GA@public.gmane.org> wrote:> Have you tested your email w/o using activesupport? > > #!/bin/env ruby > > require ''net/smtp'' > > > # Helper method. > # Append _appendage_ to end of string if it already doesn''t exist > # at the end of the string. > class String #:nodoc: > def appendIfMissing(appendage) > return self if appendage.nil? || appendage.size < 1 > return appendage if size < 1 > if self[-appendage.size..-1] == appendage > self > else > self + appendage > end > end > end > > > class String #:nodoc: > def blank? > empty? || strip.empty? > end > end > > > # Print an error message. > def err(msg, printRubyErr=false, fatal=true) #:nodoc: > STDERR.print "\n### ERROR: #{msg}\n\n" > STDERR.print "\n#{$!}\n\n" if printRubyErr > exit if fatal > "### ERROR: #{msg}\n#{$!}\n" > end > > > > # simple check of email address. > def checkMailAddress(address, descr) #:nodoc: > address.strip! > addr = address[/<?\w+@\w+\.\w+>?$/] > if addr.blank? > err(descr,false,false) > return nil > end > addr > end > > > # Send email. > def mail( od ) > # The email is composed of the ''From'', ''To'', and ''Subject'' fields, followed by the body text. > # Strip off leading white space. > (msgstr = <<END_OF_MAIL_MESSAGE).gsub!(/^\s+/, '''') > From: #{od[''-='']} > To: #{od[''-t'']} > Subject: #{od[''-j''].blank? ? ''No Subject'' : od[''-j'']} > > > END_OF_MAIL_MESSAGE > > msgstr += od[''-b''] > > return if (addr_from = checkMailAddress(od[''-=''], "no ''From'' address (#{od[''-='']})") ).nil? > return if (addr_to = checkMailAddress(od[''-t''], "no ''To'' address (#{od[''-t'']})") ).nil? > > # The email is actually sent here. > begin > Net::SMTP.start(od[''-m''], 25, od[''-n''], od[''-S''], od[''-P''], :login) { |smtp| > smtp.send_message msgstr, addr_from, addr_to > } > > puts "-- mail sent to #{addr_to}" if od[''-V''] > rescue Exception => ex > err("unable to send mail.\n#{msgstr}\n#{$!}\naddr from:#{addr_from}\naddr to:#{addr_to}", true) > end > end # mail > > od = { ''-='' => ''My Long Name<user-ND7put3rsLk@public.gmane.org>'', # mail from > ''-t'' => ''My Long Name<user-ND7put3rsLk@public.gmane.org>'', # mail to > ''-j'' => ''This is a test'', # mail subject > ''-b'' => ''Body text of the email.'', # mail body text > ''-m'' => ''smtp.XXX.net'', # mail server > ''-n'' => ''www.XXX.net'', # domain sending mail from > ''-S'' => ''mailusername'', # mail user name > ''-P'' => ''super_secret_password'', # mail password > ''-V'' => true } > > mail od > > __END__ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://www.ShadReynolds.com http://www.flickr.com/photos/shadreynolds/