Class: Net::POPMail
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/net/pop.rb |
Overview
Class Method Summary
- .new(num, len, pop, cmd) ⇒ POPMail constructor Internal use only
Instance Attribute Summary
-
#deleted? ⇒ Boolean
readonly
True if the mail has been deleted.
-
#length
(also: #size)
readonly
The length of the message in octets.
-
#number
readonly
The sequence number of the message on the server.
-
#size
readonly
Alias for #length.
-
#uid=(uid)
writeonly
Internal use only
internal use only.
Instance Method Summary
-
#delete
(also: #delete!)
Marks a message for deletion on the server.
-
#header(dest = +''))
Fetches the message header.
-
#inspect
Provide human-readable stringification of class state.
-
#pop(dest = +'',, &block)
(also: #all, #mail)
This method fetches the message.
-
#top(lines, dest = +''))
Fetches the message header and
lines
lines of body. -
#uidl
Alias for #unique_id.
-
#unique_id
(also: #uidl)
Returns the unique-id of the message.
-
#all(dest = +'',, &block)
Internal use only
Alias for #pop.
-
#delete!
Internal use only
Alias for #delete.
-
#mail(dest = +'',, &block)
Internal use only
Alias for #pop.
Constructor Details
.new(num, len, pop, cmd) ⇒ POPMail
Instance Attribute Details
#deleted? ⇒ Boolean
(readonly)
True if the mail has been deleted.
# File 'lib/net/pop.rb', line 869
def deleted? @deleted end
#length (readonly) Also known as: #size
The length of the message in octets.
# File 'lib/net/pop.rb', line 759
attr_reader :length
#number (readonly)
The sequence number of the message on the server.
# File 'lib/net/pop.rb', line 756
attr_reader :number
#size (readonly)
Alias for #length.
# File 'lib/net/pop.rb', line 760
alias size length
#uid=(uid) (writeonly)
internal use only
# File 'lib/net/pop.rb', line 885
def uid=(uid) #:nodoc: internal use only @uid = uid end
Instance Method Details
#all(dest = +'',, &block)
Alias for #pop.
# File 'lib/net/pop.rb', line 817
alias all pop #:nodoc: obsolete
#delete Also known as: #delete!
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.
Example
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 861
def delete @command.dele @number @deleted = true end
#delete!
Alias for #delete.
# File 'lib/net/pop.rb', line 866
alias delete! delete #:nodoc: obsolete
#header(dest = +''))
Fetches the message header.
The optional dest
argument is obsolete.
This method raises a POPError
if an error occurs.
# File 'lib/net/pop.rb', line 837
def header(dest = +'') top(0, dest) end
#inspect
Provide human-readable stringification of class state.
# File 'lib/net/pop.rb', line 763
def inspect +"#<#{self.class} #{@number}#{@deleted ? ' deleted' : ''}>" end
#mail(dest = +'',, &block)
Alias for #pop.
# File 'lib/net/pop.rb', line 818
alias mail pop #:nodoc: obsolete
#pop(dest = +'',, &block) Also known as: #all, #mail
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.
Example without block
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
Example with block
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 805
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
#top(lines, dest = +''))
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 'lib/net/pop.rb', line 825
def top(lines, dest = +'') @command.top(@number, lines) do |chunk| dest << chunk end dest end
#uidl
Alias for #unique_id.
# File 'lib/net/pop.rb', line 883
alias uidl unique_id
#unique_id Also known as: #uidl
Returns the unique-id of the message. Normally the unique-id is a hash string of the message.
This method raises a POPError
if an error occurs.
# File 'lib/net/pop.rb', line 877
def unique_id return @uid if @uid @pop.set_all_uids @uid end