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

Methods

External Aliases

new -> newobj

Public Class methods

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

Public Instance methods

each( &block )

Alias for each_port

 old #each_mail returns Port

def each_mail( &block )

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

end

reverse_each( &block )

Alias for reverse_each_port

[Validate]