# Net::POP3::POPMail (Class)

In: | 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.

## Methods

all delete delete! deleted? header inspect mail pop top uidl unique_id

## External Aliases

length -> size

## Attributes

length | [R] | The length of the message in octets.
number | [R] | The sequence number of the message on the server.

## Public Instance methods

inspect()

Provide human-readable stringification of class state.

[Source]

    # File net/pop.rb, line 605
        def inspect
          "#<#{self.class} #{@number}#{@deleted ? ' deleted' : ''}>"
        end

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') {|pop|
          n = 1
          pop.mails.each do |popmail|
            File.open("inbox/#{n}", 'w') {|f|
              f.write popmail.pop
            }
            popmail.delete
            n += 1
          end
        }

        # Example with block
        POP3.start('pop.example.com', 110,
                   'YourAccount, 'YourPassword') {|pop|
          n = 1
          pop.mails.each do |popmail|
            File.open("inbox/#{n}", 'w') {|f|
              popmail.pop do |chunk|            ####
                f.write chunk
              end
            }
            n += 1
          end
        }

This method raises a POPError if an error occurs.

[Source]

    # File net/pop.rb, line 643
        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

all( dest = '' )

Alias for pop

mail( dest = '' )

Alias for pop

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.

[Source]

    # File net/pop.rb, line 662
        def top( lines, dest = '' )
          @command.top(@number, lines) do |chunk|
            dest << chunk
          end
          dest
        end

header( dest = '' )

Fetches the message header. The optional `dest` argument is obsolete.

This method raises a POPError if an error occurs.

[Source]

    # File net/pop.rb, line 673
        def header( dest = '' )
          top(0, dest)
        end

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') {|pop|
          n = 1
          pop.mails.each do |popmail|
            File.open("inbox/#{n}", 'w') {|f|
              f.write popmail.pop
            }
            popmail.delete         ####
            n += 1
          end
        }

[Source]

    # File net/pop.rb, line 696
        def delete
          @command.dele @number
          @deleted = true
        end

delete!()

Alias for delete

deleted?()

True if the mail has been deleted.

[Source]

    # File net/pop.rb, line 704
        def deleted?
          @deleted
        end

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.

[Source]

    # File net/pop.rb, line 712
        def unique_id
          return @uid if @uid
          @pop.set_all_uids
          @uid
        end

uidl()

Alias for unique_id

[Validate]