Socket emergency

Oh I forgot to mention that while you comment on this, please note that the
local POP server (Norman) is ok, because I tried several mail clients it
worked (Becky, OE, Outlook…).

Thanks!
Shannon

···

From: ts decoux@moulon.inra.fr
Reply-To: ruby-talk@ruby-lang.org
To: ruby-talk@ruby-lang.org (ruby-talk ML)
CC: ruby-talk@ruby-lang.org
Subject: Re: socket emergency
Date: Thu, 21 Aug 2003 00:03:45 +0900

It hangs here.

Have you tried with the module ‘net/pop’ to see if it do the same ?

=== Enshort Code

The example above is very verbose. You can enshort code by using
some utility methods. At first, block form of Net::POP3.start can
alternates POP3.new, POP3#start and POP3#finish.

require 'net/pop'

Net::POP3.start('pop.example.com', 110,
                'YourAccount', 'YourPassword') {|pop|
  if pop.mails.empty?
    puts 'no mail.'
  else
    i = 0
    pop.each_mail do |m|   # or "pop.mails.each ..."
      File.open("inbox/#{i}", 'w') {|f|
        f.write m.pop
      }
      m.delete
      i += 1
    end
    puts "#{pop.mails.size} mails popped."
  end
}

Guy Decoux


Sign-up for a FREE BT Broadband connection today!
http://www.msn.co.uk/specials/btbroadband