U:RDoc::NormalClass[iI" POP3:ETI"Net::POP3;TI" Protocol;To:RDoc::Markup::Document: @parts[o;;[.S:RDoc::Markup::Heading: leveli: textI"What is This Library?;To:RDoc::Markup::BlankLineo:RDoc::Markup::Paragraph;[I"8This library provides functionality for retrieving ;TI"Eemail via POP3, the Post Office Protocol version 3. For details ;TI"Bof POP3, see [RFC1939] (http://www.ietf.org/rfc/rfc1939.txt).;T@S; ; i; I" Examples;T@S; ; i; I"Retrieving Messages;T@o; ;[I"FThis example retrieves messages from the server and deletes them ;TI"on the server.;T@o; ;[ I"DMessages are written to files named 'inbox/1', 'inbox/2', .... ;TI"BReplace 'pop.example.com' with your POP3 server address, and ;TI"C'YourAccount' and 'YourPassword' with the appropriate account ;TI" details.;T@o:RDoc::Markup::Verbatim;[I"require 'net/pop' ;TI" ;TI",pop = Net::POP3.new('pop.example.com') ;TI"@pop.start('YourAccount', 'YourPassword') # (1) ;TI"if pop.mails.empty? ;TI" puts 'No mail.' ;TI" else ;TI" i = 0 ;TI"@ pop.each_mail do |m| # or "pop.mails.each ..." # (2) ;TI"- File.open("inbox/#{i}", 'w') do |f| ;TI" f.write m.pop ;TI" end ;TI" m.delete ;TI" i += 1 ;TI" end ;TI". puts "#{pop.mails.size} mails popped." ;TI" end ;TI"@pop.finish # (3) ;T: @format0o:RDoc::Markup::List: @type: NUMBER: @items[o:RDoc::Markup::ListItem: @label0;[o; ;[I"0Call Net::POP3#start and start POP session.;To;;0;[o; ;[I"?Access messages by using POP3#each_mail and/or POP3#mails.;To;;0;[o; ;[I"NClose POP session by calling POP3#finish or use the block form of #start.;T@S; ; i; I"Shortened Code;T@o; ;[I"JThe example above is very verbose. You can shorten the code by using ;TI"Hsome utility methods. First, the block form of Net::POP3.start can ;TI"=be used instead of POP3.new, POP3#start and POP3#finish.;T@o;;[I"require 'net/pop' ;TI" ;TI"-Net::POP3.start('pop.example.com', 110, ;TI"= 'YourAccount', 'YourPassword') do |pop| ;TI" if pop.mails.empty? ;TI" puts 'No mail.' ;TI" else ;TI" i = 0 ;TI": pop.each_mail do |m| # or "pop.mails.each ..." ;TI"/ File.open("inbox/#{i}", 'w') do |f| ;TI" f.write m.pop ;TI" end ;TI" m.delete ;TI" i += 1 ;TI" end ;TI"0 puts "#{pop.mails.size} mails popped." ;TI" end ;TI" end ;T;0o; ;[I"BPOP3#delete_all is an alternative for #each_mail and #delete.;T@o;;[I"require 'net/pop' ;TI" ;TI"-Net::POP3.start('pop.example.com', 110, ;TI"= 'YourAccount', 'YourPassword') do |pop| ;TI" if pop.mails.empty? ;TI" puts 'No mail.' ;TI" else ;TI" i = 1 ;TI" pop.delete_all do |m| ;TI"/ File.open("inbox/#{i}", 'w') do |f| ;TI" f.write m.pop ;TI" end ;TI" i += 1 ;TI" end ;TI" end ;TI" end ;T;0o; ;[I")And here is an even shorter example.;T@o;;[I"require 'net/pop' ;TI" ;TI" i = 0 ;TI"2Net::POP3.delete_all('pop.example.com', 110, ;TI"@ 'YourAccount', 'YourPassword') do |m| ;TI"+ File.open("inbox/#{i}", 'w') do |f| ;TI" f.write m.pop ;TI" end ;TI" i += 1 ;TI" end ;T;0S; ; i; I"Memory Space Issues;T@o; ;[I"@All the examples above get each message as one big string. ;TI"This example avoids this.;T@o;;[I"require 'net/pop' ;TI" ;TI" i = 1 ;TI"2Net::POP3.delete_all('pop.example.com', 110, ;TI"@ 'YourAccount', 'YourPassword') do |m| ;TI"+ File.open("inbox/#{i}", 'w') do |f| ;TI"? m.pop do |chunk| # get a message little by little. ;TI" f.write chunk ;TI" end ;TI" i += 1 ;TI" end ;TI" end ;T;0S; ; i; I"Using APOP;T@o; ;[I"7The net/pop library supports APOP authentication. ;TI"JTo use APOP, use the Net::APOP class instead of the Net::POP3 class. ;TI"CYou can use the utility method, Net::POP3.APOP(). For example:;T@o;;[ I"require 'net/pop' ;TI" ;TI"2# Use APOP authentication if $isapop == true ;TI"Apop = Net::POP3.APOP($is_apop).new('apop.example.com', 110) ;TI"6pop.start(YourAccount', 'YourPassword') do |pop| ;TI"' # Rest of the code is the same. ;TI" end ;T;0S; ; i; I"6Fetch Only Selected Mail Using 'UIDL' POP Command;T@o; ;[I"5If your POP server provides UIDL functionality, ;TI";you can grab only selected mails from the POP server. ;TI" e.g.;T@o;;[I"def need_pop?( id ) ;TI"/ # determine if we need pop this mail... ;TI" end ;TI" ;TI"-Net::POP3.start('pop.example.com', 110, ;TI"? 'Your account', 'Your password') do |pop| ;TI"C pop.mails.select { |m| need_pop?(m.unique_id) }.each do |m| ;TI" do_something(m.pop) ;TI" end ;TI" end ;T;0o; ;[I"NThe POPMail#unique_id() method returns the unique-id of the message as a ;TI"=String. Normally the unique-id is a hash of the message.;T: @fileI"lib/net/pop.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[ I" address;TI"R;T: publicFI"lib/net/pop.rb;T[ I"open_timeout;TI"RW;T;F@Ã[ I"read_timeout;TI"R;T;F@Ã[U:RDoc::Constant[iI" Revision;FI"Net::POP3::Revision;T00o;;[o; ;[I"!svn revision of this library;T;@¾;0@¾@cRDoc::NormalClass0[[[I" class;T[[;[[I" APOP;F@Ã[I"auth_only;F@Ã[I" certs;F@Ã[I"create_ssl_params;F@Ã[I"default_pop3_port;F@Ã[I"default_pop3s_port;F@Ã[I"default_port;F@Ã[I"delete_all;F@Ã[I"disable_ssl;F@Ã[I"enable_ssl;F@Ã[I" foreach;F@Ã[I"new;T@Ã[I"ssl_params;F@Ã[I" start;F@Ã[I" use_ssl?;F@Ã[I" verify;F@Ã[:protected[[: private[[I" instance;T[[;[[I" active?;F@Ã[I" apop?;F@Ã[I"auth_only;F@Ã[I"delete_all;F@Ã[I"disable_ssl;F@Ã[I" each;F@Ã[I"each_mail;F@Ã[I"enable_ssl;F@Ã[I" finish;F@Ã[I" inspect;F@Ã[I" logging;F@Ã[I" mails;F@Ã[I" n_bytes;F@Ã[I" n_mails;F@Ã[I" port;F@Ã[I"read_timeout=;F@Ã[I" reset;F@Ã[I"set_debug_output;F@Ã[I" start;F@Ã[I" started?;F@Ã[I" use_ssl?;F@Ã[;[[;[[[U:RDoc::Context::Section[i0o;;[;0;0[@¾I"Net;FcRDoc::NormalModule