Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcMailStorageSet

Mail::ezcMailStorageSet

Class ezcMailStorageSet

ezcMailStorageSet is a wrapper around other mail sets and provides saving of mail sources to files.

Example:

  1.  // create a new POP3 transport object and a mail parser object
  2.  $transport = new ezcMailPop3Transport( "server" );
  3.  $transport->authenticate( "username", "password" );
  4.  $parser = new ezcMailParser();
  5.  
  6.  // wrap around the set returned by fetchAll()
  7.  // and specify that the sources are to be saved in the folder /tmp/cache
  8.  $set = new ezcMailStorageSet( $transport->fetchAll(), '/tmp/cache' );
  9.  
  10.  // parse the storage set
  11.  $mail = $parser->parseMail( $set );
  12.  
  13.  // get the filenames of the saved mails in the set.
  14.  // The file names are composed of process ID + current time + a counter
  15.  // This array must be saved to be used on a subsequent request
  16.  $files = $set->getSourceFiles();
  17.  
  18.  // get the source of the 4th saved mail.
  19.  // This can be on a subsequent request if the $files array was saved from
  20.  // a previous request
  21.  $source = file_get_contents( $files[3] );

Source for this file: /Mail/src/transports/storage/storage_set.php

Implements interfaces:

Version:   //autogen//

Method Summary

public ezcMailStorageSet __construct( $set , $location )
Constructs a new storage set around the provided set.
public void __destruct( )
Destructs the set.
public string getNextLine( )
Returns one line of data from the current mail in the set.
public array(string) getSourceFiles( )
Returns an array of the filenames holding the sources of the mails in this set.
public bool hasData( )
Returns whether the set has mails.
public bool nextMail( )
Moves the set to the next mail and returns true upon success.

Methods

__construct

ezcMailStorageSet __construct( ezcMailParserSet $set , string $location )

Constructs a new storage set around the provided set.

$location specifies where to save the message sources. This directory MUST exist and must be writable.

Parameters:
Name Type Description
$set ezcMailParserSet
$location string

__destruct

void __destruct( )

Destructs the set.

Closes any open files.

getNextLine

string getNextLine( )

Returns one line of data from the current mail in the set.

Null is returned if there is no current mail in the set or the end of the mail is reached,

It also writes the line of data to the current file. If the line contains a Message-ID header then the value in the header will be used to rename the file.

Implementation of:
Method Description
ezcMailParserSet::getNextLine() Returns one line of data from the current mail in the set including the ending linebreak.

getSourceFiles

array(string) getSourceFiles( )

Returns an array of the filenames holding the sources of the mails in this set.

The format of the returned array is: array( 0 => 'location/filename1', 1 => 'location/filename2',...)

hasData

bool hasData( )

Returns whether the set has mails.

Implementation of:
Method Description
ezcMailParserSet::hasData() Returns true if mail data is available for parsing.

nextMail

bool nextMail( )

Moves the set to the next mail and returns true upon success.

False is returned if there are no more mail in the set.

Implementation of:
Method Description
ezcMailParserSet::nextMail() Moves the set to the next mail and returns true upon success.
Documentation generated by phpDocumentor 1.4.3