Class

Net::POPMail

Inheritance
< 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.

Attributes

Name Visibility R/W Description
length public R The length of the message in octets.
number public R The sequence number of the message on the server.

Aliases

Method Alias Description
length → size

Methods

Instance

Visibility Signature
public all ( dest = '' )
public delete ()
public delete! ()
public deleted? ()
public header (dest = '')
public inspect ()
public mail ( dest = '' )
public pop ( dest = '' ) {|message_chunk| ...}
public top (lines, dest = '')
public uidl ()
public unique_id ()

Instance Method Detail

all( dest = '' )

Alias for pop

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

delete!()

Alias for delete

deleted?()

True if the mail has been deleted.

header(dest = '')

Fetches the message header.

The optional dest argument is obsolete.

This method raises a POPError if an error occurs.

inspect()

Provide human-readable stringification of class state.

mail( dest = '' )

Alias for pop

pop( dest = '' ) {|message_chunk| ...}

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.

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.

uidl()

Alias for unique_id

unique_id()

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.