Current File : //proc/thread-self/root/proc/self/root/opt/alt/ruby18/share/ri/1.8/system/Net/POP3/cdesc-POP3.yaml |
--- !ruby/object:RI::ClassDescription
attributes:
- !ruby/object:RI::Attribute
comment:
- !ruby/struct:SM::Flow::P
body: The address to connect to.
name: address
rw: R
- !ruby/object:RI::Attribute
comment:
- !ruby/struct:SM::Flow::P
body: Seconds to wait until a connection is opened. If the POP3 object cannot open a connection within this time, it raises a TimeoutError exception.
name: open_timeout
rw: RW
- !ruby/object:RI::Attribute
comment:
- !ruby/struct:SM::Flow::P
body: Seconds to wait until reading one block (by one read(1) call). If the POP3 object cannot complete a read() within this time, it raises a TimeoutError exception.
name: read_timeout
rw: R
class_methods:
- !ruby/object:RI::MethodSummary
name: APOP
- !ruby/object:RI::MethodSummary
name: auth_only
- !ruby/object:RI::MethodSummary
name: certs
- !ruby/object:RI::MethodSummary
name: create_ssl_params
- !ruby/object:RI::MethodSummary
name: default_pop3_port
- !ruby/object:RI::MethodSummary
name: default_pop3s_port
- !ruby/object:RI::MethodSummary
name: default_port
- !ruby/object:RI::MethodSummary
name: delete_all
- !ruby/object:RI::MethodSummary
name: disable_ssl
- !ruby/object:RI::MethodSummary
name: enable_ssl
- !ruby/object:RI::MethodSummary
name: foreach
- !ruby/object:RI::MethodSummary
name: new
- !ruby/object:RI::MethodSummary
name: ssl_params
- !ruby/object:RI::MethodSummary
name: start
- !ruby/object:RI::MethodSummary
name: use_ssl?
- !ruby/object:RI::MethodSummary
name: verify
comment:
- !ruby/struct:SM::Flow::H
level: 1
text: Net::POP3
- !ruby/struct:SM::Flow::H
level: 2
text: What is This Library?
- !ruby/struct:SM::Flow::P
body: This library provides functionality for retrieving email via POP3, the Post Office Protocol version 3. For details of POP3, see [RFC1939] (http://www.ietf.org/rfc/rfc1939.txt).
- !ruby/struct:SM::Flow::H
level: 2
text: Examples
- !ruby/struct:SM::Flow::H
level: 3
text: Retrieving Messages
- !ruby/struct:SM::Flow::P
body: This example retrieves messages from the server and deletes them on the server.
- !ruby/struct:SM::Flow::P
body: Messages are written to files named 'inbox/1', 'inbox/2', .... Replace 'pop.example.com' with your POP3 server address, and 'YourAccount' and 'YourPassword' with the appropriate account details.
- !ruby/struct:SM::Flow::VERB
body: " require 'net/pop'\n\n pop = Net::POP3.new('pop.example.com')\n pop.start('YourAccount', 'YourPassword') # (1)\n if pop.mails.empty?\n puts 'No mail.'\n else\n i = 0\n pop.each_mail do |m| # or "pop.mails.each ..." # (2)\n File.open("inbox/#{i}", 'w') do |f|\n f.write m.pop\n end\n m.delete\n i += 1\n end\n puts "#{pop.mails.size} mails popped."\n end\n pop.finish # (3)\n"
- !ruby/object:SM::Flow::LIST
contents:
- !ruby/struct:SM::Flow::LI
label: "1."
body: Call Net::POP3#start and start POP session.
- !ruby/struct:SM::Flow::LI
label: "2."
body: Access messages by using POP3#each_mail and/or POP3#mails.
- !ruby/struct:SM::Flow::LI
label: "3."
body: "Close POP session by calling POP3#finish or use the block form of #start."
type: :NUMBER
- !ruby/struct:SM::Flow::H
level: 3
text: Shortened Code
- !ruby/struct:SM::Flow::P
body: The example above is very verbose. You can shorten the code by using some utility methods. First, the block form of Net::POP3.start can be used instead of POP3.new, POP3#start and POP3#finish.
- !ruby/struct:SM::Flow::VERB
body: " require 'net/pop'\n\n Net::POP3.start('pop.example.com', 110,\n 'YourAccount', 'YourPassword') do |pop|\n if pop.mails.empty?\n puts 'No mail.'\n else\n i = 0\n pop.each_mail do |m| # or "pop.mails.each ..."\n File.open("inbox/#{i}", 'w') do |f|\n f.write m.pop\n end\n m.delete\n i += 1\n end\n puts "#{pop.mails.size} mails popped."\n end\n end\n"
- !ruby/struct:SM::Flow::P
body: "POP3#delete_all is an alternative for #each_mail and #delete."
- !ruby/struct:SM::Flow::VERB
body: " require 'net/pop'\n\n Net::POP3.start('pop.example.com', 110,\n 'YourAccount', 'YourPassword') do |pop|\n if pop.mails.empty?\n puts 'No mail.'\n else\n i = 1\n pop.delete_all do |m|\n File.open("inbox/#{i}", 'w') do |f|\n f.write m.pop\n end\n i += 1\n end\n end\n end\n"
- !ruby/struct:SM::Flow::P
body: And here is an even shorter example.
- !ruby/struct:SM::Flow::VERB
body: " require 'net/pop'\n\n i = 0\n Net::POP3.delete_all('pop.example.com', 110,\n 'YourAccount', 'YourPassword') do |m|\n File.open("inbox/#{i}", 'w') do |f|\n f.write m.pop\n end\n i += 1\n end\n"
- !ruby/struct:SM::Flow::H
level: 3
text: Memory Space Issues
- !ruby/struct:SM::Flow::P
body: All the examples above get each message as one big string. This example avoids this.
- !ruby/struct:SM::Flow::VERB
body: " require 'net/pop'\n\n i = 1\n Net::POP3.delete_all('pop.example.com', 110,\n 'YourAccount', 'YourPassword') do |m|\n File.open("inbox/#{i}", 'w') do |f|\n m.pop do |chunk| # get a message little by little.\n f.write chunk\n end\n i += 1\n end\n end\n"
- !ruby/struct:SM::Flow::H
level: 3
text: Using APOP
- !ruby/struct:SM::Flow::P
body: "The net/pop library supports APOP authentication. To use APOP, use the Net::APOP class instead of the Net::POP3 class. You can use the utility method, Net::POP3.APOP(). For example:"
- !ruby/struct:SM::Flow::VERB
body: " require 'net/pop'\n\n # Use APOP authentication if $isapop == true\n pop = Net::POP3.APOP($is_apop).new('apop.example.com', 110)\n pop.start(YourAccount', 'YourPassword') do |pop|\n # Rest of the code is the same.\n end\n"
- !ruby/struct:SM::Flow::H
level: 3
text: Fetch Only Selected Mail Using 'UIDL' POP Command
- !ruby/struct:SM::Flow::P
body: If your POP server provides UIDL functionality, you can grab only selected mails from the POP server. e.g.
- !ruby/struct:SM::Flow::VERB
body: " def need_pop?( id )\n # determine if we need pop this mail...\n end\n\n Net::POP3.start('pop.example.com', 110,\n 'Your account', 'Your password') do |pop|\n pop.mails.select { |m| need_pop?(m.unique_id) }.each do |m|\n do_something(m.pop)\n end\n end\n"
- !ruby/struct:SM::Flow::P
body: The POPMail#unique_id() method returns the unique-id of the message as a String. Normally the unique-id is a hash of the message.
constants:
- !ruby/object:RI::Constant
comment:
name: Revision
value: "%q$Revision: 29903 $.split[1]"
full_name: Net::POP3
includes: []
instance_methods:
- !ruby/object:RI::MethodSummary
name: active?
- !ruby/object:RI::MethodSummary
name: apop?
- !ruby/object:RI::MethodSummary
name: auth_only
- !ruby/object:RI::MethodSummary
name: command
- !ruby/object:RI::MethodSummary
name: delete_all
- !ruby/object:RI::MethodSummary
name: disable_ssl
- !ruby/object:RI::MethodSummary
name: do_finish
- !ruby/object:RI::MethodSummary
name: do_start
- !ruby/object:RI::MethodSummary
name: each
- !ruby/object:RI::MethodSummary
name: each_mail
- !ruby/object:RI::MethodSummary
name: enable_ssl
- !ruby/object:RI::MethodSummary
name: finish
- !ruby/object:RI::MethodSummary
name: inspect
- !ruby/object:RI::MethodSummary
name: logging
- !ruby/object:RI::MethodSummary
name: mails
- !ruby/object:RI::MethodSummary
name: n_bytes
- !ruby/object:RI::MethodSummary
name: n_mails
- !ruby/object:RI::MethodSummary
name: on_connect
- !ruby/object:RI::MethodSummary
name: port
- !ruby/object:RI::MethodSummary
name: read_timeout=
- !ruby/object:RI::MethodSummary
name: reset
- !ruby/object:RI::MethodSummary
name: set_debug_output
- !ruby/object:RI::MethodSummary
name: start
- !ruby/object:RI::MethodSummary
name: started?
- !ruby/object:RI::MethodSummary
name: use_ssl?
name: POP3
superclass: Protocol