require 'net/pop' pop = Net::POP3.new('pop3.example.com') pop.start('YourAccount', 'YourPassword') if pop.mails.empty? puts 'No mail.' else i = 0 pop.each_mail do |m| File.open("inbox/#{i}", 'w') do |f| f.write m.pop end m.delete i += 1 end puts "#{pop.mails.size} mails popped." end pop.finish
?
更多例子请参考http://www.ensta-paristech.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/pop/rdoc/classes/Net/POP3.html