Path

ez components / documentation / api reference / 2007.2 / mail


Mail: ezcMailParser

[ Tutorial ] [ Display example ] [ Mail listing example ] [ Rfcs ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Class: ezcMailParser

Parses a mail in RFC822 format to an ezcMail structure. [source]
If you want to use your own mail class (extended from ezcMail), use ezcMailParserOption. Example:
1.  $options new ezcMailParserOptions();
2.  $options->mailClass 'MyMailClass';
3.  
4.  $parser new ezcMailParser$options );
4.  // if you want to use MyMailClass which extends ezcMail
File attachments will be written to disk in a temporary directory. This temporary directory and the file attachment will be removed when PHP ends execution. If you want to keep the file you should move it to another directory.

Properties

ezcMailParserOptions read/write  $options
Holds the options you can set to the mail parser.

Method Summary

public ezcMailParser __construct( [$options = array()] )
Constructs a new mail parser.
public static string getTmpDir( )
Returns the temporary directory.
public array(ezcMail) parseMail( $set, [$class = null] )
Returns an array of ezcMail objects parsed from the mail set $set.
public static void setTmpDir( $dir )
Sets the temporary directory.

Methods

__construct

ezcMailParser __construct( [ezcMailParserOptions|array(string=>mixed) $options = array()] )
Constructs a new mail parser.
For options you can set to the mail parser see ezcMailParserOptions.

Parameters

Name Type Description
$options ezcMailParserOptions|array(string=>mixed)  

Throws

ClassDescription
ezcBasePropertyNotFoundException if $options contains a property not defined
ezcBaseValueException if $options contains a property with a value not allowed

getTmpDir

string getTmpDir( )
Returns the temporary directory.
If no temporary directory has been set this method defaults to /tmp/ for linux and c:\tmp\ for windows.

parseMail

array(ezcMail) parseMail( ezcMailParserSet $set, [string $class = null] )
Returns an array of ezcMail objects parsed from the mail set $set.
You can optionally use ezcMailParserOptions to provide an alternate class name which will be instantiated instead of ezcMail, if you need to extend ezcMail.
Example:
1.  $options new ezcMailParserOptions();
2.  $options->mailClass 'MyMailClass';
3.  
4.  $parser new ezcMailParser$options );
4.  // if you want to use MyMailClass which extends ezcMail

Parameters

Name Type Description
$set ezcMailParserSet  
$class string Deprecated. Use $mailClass in ezcMailParserOptions class instead.

Throws

ClassDescription
ezcBaseFileNotFoundException if a neccessary temporary file could not be openened.

setTmpDir

void setTmpDir( string $dir )
Sets the temporary directory.
The temporary directory must be writeable by PHP. It will be used to store file attachments.

Parameters

Name Type Description
$dir string  

Last updated: Mon, 17 Dec 2007