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

### Mail::ezcMailPart

### Class ezcMailPart

Abstract base class for all mail MIME parts.

This base class provides functionality to store headers and to generate the mail part. Implementations of this class must handle the body of that parts themselves. They must also implement generateBody() which is called when the message part is generated.

Source for this file: /Mail/src/interfaces/part.php

Version: | //autogen//

### Descendants

Child Class | Description
--- | ---
ezcMailDeliveryStatus | Mail part used for sending delivery status message.
ezcMailMultipart | Abstract base class for all multipart types.
ezcMailText | Mail part used for sending all forms of plain text.
ezcMailRfc822Digest | Mail part or mail digest parts.
ezcMailFilePart | Mail part for all forms of binary data.
ezcMail | The main mail class.

### Properties

ezcMailContentDispositionHeader

read/write

`$contentDisposition`
Contains the information from the Content-Disposition field of this mail. This useful especially when you are investigating retrieved mail to see if a part is an attachment or should be displayed inline. However, it can also be used to set the same on outgoing mail. Note that the ezcMailFile part sets the Content-Disposition field itself based on it's own properties when sending mail.

ezcMailHeadersHolder | read | `$headers` Contains the header holder object, taking care of the headers of this part. Can be retreived for reasons of extending this class and its derivals.
int | read/write | `$size` The size of the mail part in bytes. It is set when parsing a mail ezcMailParser->parseMail().

### Member Variables

protected array(string=>mixed) | `$properties = array()` Holds the properties of this class.

### Method Summary

public ezcMailPart | `__construct( )` Constructs a new mail part.
public void | `appendExcludeHeaders( $headers )` The array $headers will be excluded when the headers are generated.
public string | `generate( )` Returns the complete mail part including both the header and the body as a string.
public abstract string | `generateBody( )` Returns the body of this part as a string.
public string | `generateHeaders( )` Returns the headers set for this part as a RFC 822 string.
public mixed | `getHeader( $name , [ $returnAllValues = false] )` Returns the RAW value of the header $name.
protected string | `getHeaderCharset( $name )` Returns the charset registered for the header $name.
public void | `setHeader( $name , $value , [ $charset = 'us-ascii'] )` Sets the header $name to the value $value and its charset to $charset.
protected void | `setHeaderCharset( $name , [ $value = 'us-ascii'] )` Sets the charset of the header $name to $value.
public void | `setHeaders( $headers )` Adds the headers $headers.

### Methods

#### __construct

ezcMailPart __construct( )

Constructs a new mail part.

##### Redefined in descendants as:

Method | Description
--- | ---
`ezcMailDeliveryStatus::__construct()` | Constructs a new DeliveryStatus part.
`ezcMailMultipart::__construct()` | Constructs a new ezcMailMultipart with the parts $parts.
`ezcMailMultipartMixed::__construct()` | Constructs a new ezcMailMultipartMixed
`ezcMailMultipartAlternative::__construct()` | Constructs a new ezcMailMultipartAlternative
`ezcMailMultipartReport::__construct()` | Constructs a new ezcMailMultipartReport.
`ezcMailMultipartDigest::__construct()` | Constructs a new ezcMailMultipartDigest
`ezcMailMultipartRelated::__construct()` | Constructs a new ezcMailMultipartRelated.
`ezcMailText::__construct()` | Constructs a new TextPart with the given $text, $charset and $encoding.
`ezcMailRfc822Digest::__construct()` | Constructs a new ezcMailDigest with the mail $mail.
`ezcMailFilePart::__construct()` | Constructs a new attachment with $fileName.
`ezcMailVirtualFile::__construct()` | Constructs a new attachment with $fileName and $contents.
`ezcMailStreamFile::__construct()` | Constructs a new attachment with $fileName and $stream.
`ezcMailFile::__construct()` | Constructs a new attachment with $fileName.
`ezcMail::__construct()` | Constructs an empty ezcMail object.
`ezcMailComposer::__construct()` | Constructs an empty ezcMailComposer object.

#### appendExcludeHeaders

void appendExcludeHeaders( $headers )

The array $headers will be excluded when the headers are generated.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$headers` | array(string) |

#### generate

string generate( )

Returns the complete mail part including both the header and the body as a string.

##### Redefined in descendants as:

Method | Description
--- | ---
`ezcMailFilePart::generate()` | Override of the generate() method from ezcMailPart. Used to set headers before generating the part.

#### generateBody

string generateBody( )

Returns the body of this part as a string.

This method is called automatically by generate() and subclasses must implement it.

##### Redefined in descendants as:

Method | Description
--- | ---
`ezcMailDeliveryStatus::generateBody()` | Returns the generated text body of this part as a string.
`ezcMailMultipart::generateBody()` | Returns the generated body for all multipart types.
`ezcMailText::generateBody()` | Returns the generated text body of this part as a string.
`ezcMailRfc822Digest::generateBody()` | Returns the body part of this mail consisting of the digested mail.
`ezcMailVirtualFile::generateBody()` | Returns the contents of the file with the correct encoding.
`ezcMailStreamFile::generateBody()` | Returns the contents of the file with the correct encoding.
`ezcMailFile::generateBody()` | Returns the contents of the file with the correct encoding.
`ezcMail::generateBody()` | Returns the generated body part of this mail.

#### generateHeaders

string generateHeaders( )

Returns the headers set for this part as a RFC 822 string.

Each header is separated by a line break. This method does not add the required two lines of space to separate the headers from the body of the part.

It also encodes the headers (with the 'Q' encoding) if the charset associated with the header is different than 'us-ascii' or if it contains characters not allowed in mail headers.

This function is called automatically by generate() and subclasses can override this method if they wish to set additional headers when the mail is generated.

##### Redefined in descendants as:

Method | Description
--- | ---
`ezcMailDeliveryStatus::generateHeaders()` | Returns the headers set for this part as a RFC822 compliant string.
`ezcMailText::generateHeaders()` | Returns the headers set for this part as a RFC822 compliant string.
`ezcMail::generateHeaders()` | Returns the generated headers for the mail.

#### getHeader

mixed getHeader( string $name , [bool $returnAllValues = false] )

Returns the RAW value of the header $name.

Returns an empty string if the header is not found. Getting headers is case insensitive. Getting the header 'Message-Id' will match both 'Message-ID' and 'MESSAGE-ID' as well as 'Message-Id'.

The raw value is MIME-encoded, so if you want to decode it, use ezcMailTools::mimeDecode() or implement your own MIME-decoding function.

If $returnAllValues is true, the function will return all the values of the header $name from the mail in an array. If it is false it will return only the first value as a string if there are multiple values present in the mail.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string |
`$returnAllValues` | bool |

#### getHeaderCharset

string getHeaderCharset( string $name )

Returns the charset registered for the header $name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string |

#### setHeader

void setHeader( string $name , string $value , [string $charset = 'us-ascii'] )

Sets the header $name to the value $value and its charset to $charset.

If the header is already set it will override the old value.

Headers set should be folded at 76 or 998 characters according to the folding rules described in RFC 2822.

If $charset is specified, it is associated with the header $name. It defaults to 'us-ascii' if not specified. The text in $value is encoded with $charset after calling generateHeaders().

Note: The header Content-Disposition will be overwritten by the contents of the contentsDisposition property if set.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string |
`$value` | string |
`$charset` | string |

#### setHeaderCharset

void setHeaderCharset( string $name , [string $value = 'us-ascii'] )

Sets the charset of the header $name to $value.

If $value is not specified it defaults to 'us-ascii'.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$name` | string |
`$value` | string |

#### setHeaders

void setHeaders( $headers )

Adds the headers $headers.

The headers specified in the associative array $headers will overwrite any existing header values.

The array $headers can have one of these 2 forms:

- array( header_name => header_value ) - by default the 'us-ascii' charset will be associated with all headers
- array( header_name => array( header_value, header_charset ) ) - if header_charset is missing it will default to 'us-ascii'

Headers set should be folded at 76 or 998 characters according to the folding rules described in RFC 2822.

##### Parameters:

Name | Type | Description
--- | --- | ---
`$headers` | array(string=>mixed) |

Documentation generated by phpDocumentor 1.4.3