## Apache Zeta Components Manual :: Docs For Class ezcMailParser

### Mail::ezcMailParser

### Class ezcMailParser

Parses a mail in RFC822 format to an ezcMail structure.

By default an object of class ezcMail is returned by the parser. If you want to use your own mail class (which extends ezcMail), use ezcMailParserOptions. Example:

1. $options=new ezcMailParserOptions ();
2. $options->mailClass='myCustomMailClass';// extends ezcMail
4. $parser=new ezcMailParser ($options);

Another way to do this is:

1. $parser=new ezcMailParser ();
2. $parser->options->mailClass='myCustomMailClass';// 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.

By default objects of class ezcMailFile are created to handle file attachments. If you want to use your own file class (which extends ezcMailFile), use ezcMailParserOptions. Example:

1. $options=new ezcMailParserOptions ();
2. $options->fileClass='myCustomFileClass';// extends ezcMailFile
4. $parser=new ezcMailParser ($options);

Another way to do this is:

1. $parser=new ezcMailParser ();
2. $parser->options->fileClass='myCustomFileClass';// extends ezcMailFile

By default objects of class ezcMailTextPart are created for text attachments. If you want to use ezcMailFile objects instead, use ezcMailParserOptions. Example:

1. $options=new ezcMailParserOptions ();
2. $options->parseTextAttachmentsAsFiles=true;
4. $parser=new ezcMailParser ($options);

Another way to do this is:

1. $parser=new ezcMailParser ();
2. $parser->options->parseTextAttachmentsAsFiles=true;

Source for this file: /Mail/src/parser/parser.php

Version: | //autogen//

### Properties

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

### Method Summary

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

### Methods

#### getTmpDir

static string getTmpDir( )

Returns the temporary directory.

Uses the PHP 5.2.1 function sys_get_temp_dir().

Note that the directory name returned will have a "slash" at the end ("/" for Linux and "\" for Windows).

#### setTmpDir

static 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 |

#### __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) |

##### Exceptions:

Type | Description
--- | ---
`ezcBaseValueException` | if $options contains a property with a value not allowed
`ezcBasePropertyNotFoundException` | if $options contains a property not defined

#### 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';
4. $parser=new ezcMailParser ($options);
5. // if you want to use MyMailClass which extends ezcMail

##### Parameters:

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

##### Exceptions:

Type | Description
--- | ---
`ezcBaseFileNotFoundException` | if a neccessary temporary file could not be openened.

Documentation generated by phpDocumentor 1.4.3