Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
Object
This class represents a message which exists on the POP server. Instances of this class are created by the POP3 class; they should not be directly created by the user.
Marks a message for deletion on the server. Deletion does not actually occur until the end of the session; deletion may be cancelled for all marked messages by calling Net::POP3#reset.
This method raises a POPError if an error occurs.
POP3.start('pop.example.com', 110, 'YourAccount, 'YourPassword') do |pop| n = 1 pop.mails.each do |popmail| File.open("inbox/#{n}", 'w') do |f| f.write popmail.pop end popmail.delete #### n += 1 end end
# File net/pop.rb, line 857 def delete @command.dele @number @deleted = true end
True if the mail has been deleted.
# File net/pop.rb, line 865 def deleted? @deleted end
Fetches the message header.
The optional dest
argument is obsolete.
This method raises a POPError if an error occurs.
# File net/pop.rb, line 833 def header(dest = '') top(0, dest) end
Provide human-readable stringification of class state.
# File net/pop.rb, line 759 def inspect "#<#{self.class} #{@number}#{@deleted ? ' deleted' : ''}>" end
This method fetches the message. If called with a block, the message is
yielded to the block one chunk at a time. If called without a block, the
message is returned as a String. The optional dest
argument
will be prepended to the returned String; this argument is essentially
obsolete.
POP3.start('pop.example.com', 110, 'YourAccount, 'YourPassword') do |pop| n = 1 pop.mails.each do |popmail| File.open("inbox/#{n}", 'w') do |f| f.write popmail.pop end popmail.delete n += 1 end end
POP3.start('pop.example.com', 110, 'YourAccount, 'YourPassword') do |pop| n = 1 pop.mails.each do |popmail| File.open("inbox/#{n}", 'w') do |f| popmail.pop do |chunk| #### f.write chunk end end n += 1 end end
This method raises a POPError if an error occurs.
# File net/pop.rb, line 801 def pop( dest = '', &block ) # :yield: message_chunk if block_given? @command.retr(@number, &block) nil else @command.retr(@number) do |chunk| dest << chunk end dest end end
Fetches the message header and lines
lines of body.
The optional dest
argument is obsolete.
This method raises a POPError if an error occurs.
# File net/pop.rb, line 821 def top(lines, dest = '') @command.top(@number, lines) do |chunk| dest << chunk end dest end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.