Class | TMail::UNIXMbox
In: | lib/action_mailer/vendor/tmail-1.2.3/tmail/mailbox.rb
Parent: | Object

### Methods

close create_from_line each each_new_port each_port fromaddr lock mkfinal new new new_port reverse_each reverse_each_port static_new

### External Aliases

new | -> | newobj

### Public Class methods

create_from_line( port )

make _From line

fromaddr(port)
lock( fname ) {|f| ...}
mkfinal( mh, mboxfile, writeback_p, cleanup_p )
new( filename, tmpdir = nil, readonly = false )

Creates a new mailbox object that you can iterate through to collect the emails from with "each_port".

You need to pass it a filename of a unix mailbox format file, the format of this file can be researched at this page at wikipedia

#### Parameters

`filename`: The filename of the mailbox you want to open

`tmpdir`: Can be set to override TMail using the system environment‘s temp dir. TMail will first use the temp dir specified by you (if any) or then the temp dir specified in the Environment‘s TEMP value then the value in the Environment‘s TMP value or failing all of the above, ’/tmp‘

`readonly`: If set to false, each email you take from the mail box will be removed from the mailbox. default is false - ie, it WILL truncate your mailbox file to ZERO once it has read the emails out.

#### Options:

None

#### Examples:

     # First show using readonly true:

     require 'ftools'
     File.size("../test/fixtures/mailbox")
     #=> 20426

     mailbox = TMail::UNIXMbox.new("../test/fixtures/mailbox", nil, true)
     #=> #<TMail::UNIXMbox:0x14a2aa8 @readonly=true.....>

     mailbox.each_port do |port|
       mail = TMail::Mail.new(port)
       puts mail.subject
     end
     #Testing mailbox 1
     #Testing mailbox 2
     #Testing mailbox 3
     #Testing mailbox 4
     require 'ftools'
     File.size?("../test/fixtures/mailbox")
     #=> 20426

     # Now show with readonly set to the default false

     mailbox = TMail::UNIXMbox.new("../test/fixtures/mailbox")
     #=> #<TMail::UNIXMbox:0x14a2aa8 @readonly=false.....>

     mailbox.each_port do |port|
       mail = TMail::Mail.new(port)
       puts mail.subject
     end
     #Testing mailbox 1
     #Testing mailbox 2
     #Testing mailbox 3
     #Testing mailbox 4

     File.size?("../test/fixtures/mailbox")
     #=> nil

new( fname, mhdir, readonly, static )
static_new( fname, dir, readonly = false )

### Public Instance methods

close()
each( &block )

Alias for each_port

each_new_port( mtime = nil ) {|p| ...}

     old #each_mail returns Port

def each_mail( &block )

      each_port do |port|
        yield Mail.new(port)
      end

end

each_port( &block )
new_port()
reverse_each( &block )

Alias for reverse_each_port

reverse_each_port( &block )

[Validate]