Hi,
I have the Nutshell book, and I've been playing with the Net classes
examples.
The FTP example works like a champ. (A dozen lines to manage a simple FTP
session...who knew :-)
However, I'm running into a little snag with the POP3 (or, more
specifically, the PopMail) class.
I just want to print the number of unread mails (which works), and the
header for each mail. But when I do this:
require 'net/pop'
mailbox = Net::POP3::new( "pop.west.cox.net" )
mails = []
mailbox.start( "dhtapp", <PW here> ) { mails = mailbox.mails }
print "# of mails: ", mails.size, "\n"
mails.each { |mail| p mail.header, "\n" }
I get:
# of mails: 1
c:/ruby/lib/ruby/1.8/net/protocol.rb:259:in `do_write': undefined method
`write'
for nil (NoMethodError)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:242:in `writeline'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:241:in `writing'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:243:in `writeline'
from c:/ruby/lib/ruby/1.8/net/pop.rb:785:in `getok'
from c:/ruby/lib/ruby/1.8/net/pop.rb:745:in `top'
from c:/ruby/lib/ruby/1.8/net/pop.rb:744:in `critical'
from c:/ruby/lib/ruby/1.8/net/pop.rb:747:in `top'
from c:/ruby/lib/ruby/1.8/net/pop.rb:657:in `top'
from c:/ruby/lib/ruby/1.8/net/pop.rb:661:in `header'
from trypop.rb:10
from trypop.rb:10:in `each'
from trypop.rb:10
I've tried moving the "p mail.header" up as a block to the mailbox.start
call, thinking that maybe the mailbox was closed by the time I tried to
print the headers out, but it made no difference. Can anyone point me to
something obvious?
Thanks,
- dan