| Class | Net::POPMail |
| In: |
lib/net/pop.rb
|
| Parent: | 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.
| length | -> | size |
| length | [R] | The length of the message in octets. |
| number | [R] | The sequence number of the message on the server. |
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 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 lib/net/pop.rb, line 836
836: def delete
837: @command.dele @number
838: @deleted = true
839: end
Provide human-readable stringification of class state.
# File lib/net/pop.rb, line 738
738: def inspect
739: "#<#{self.class} #{@number}#{@deleted ? ' deleted' : ''}>"
740: 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 lib/net/pop.rb, line 780
780: def pop( dest = '', &block ) # :yield: message_chunk
781: if block_given?
782: @command.retr(@number, &block)
783: nil
784: else
785: @command.retr(@number) do |chunk|
786: dest << chunk
787: end
788: dest
789: end
790: end