# module RMail::Mailbox

The RMail::Mailbox module contains a few methods that are useful for working with mailboxes.

### Public Class Methods

parse_mbox(input, line_separator = $/) { |raw_message| ... } click to toggle source

Parse a Unix mbox style mailbox. These mailboxes searate individual messages with a line beginning with the string “From ”.

If a block is given, yields to the block with the raw message (a string), otherwise an array of raw message strings is returned.

    # File lib/rmail/mailbox.rb, line 45
    def parse_mbox(input, line_separator = $/)
      require 'rmail/mailbox/mboxreader'
      retval = []
      RMail::Mailbox::MBoxReader.new(input, line_separator).each_message {
        |reader|
        raw_message = reader.read(nil)
        if block_given?
          yield raw_message
        else
          retval << raw_message
        end
      }
      return block_given? ? nil : retval
    end