19.2. Zend_Mime_Message
السابق | فصل 19. Zend_Mime | التالي

## 19.2. Zend_Mime_Message

### 19.2.1. Introduction

`Zend_Mime_Message` represents a MIME compliant message that can contain one or more seperate Parts (Represented as `Zend_Mime_Part` objects). With `Zend_Mime_Message`, MIME compliant multipart messages can be generated from `Zend_Mime_Part` objects. Encoding and Boundary handling are handled transparently by the class. `Zend_Mime_Message` objects can also be reconstructed from given strings (experimental). Used by `Zend_Mail`.

### 19.2.2. Instantiation

There is no explicit constructor for `Zend_Mime_Message`.

### 19.2.3. Adding MIME Parts

`Zend_Mime_Part` Objects can be added to a given `Zend_Mime_Message` object by calling `->addPart($part)`

An array with all `Zend_Mime_Part` objects in the `Zend_Mime_Message` is returned from the method `->getParts()`. The Zend_Mime_Part objects can then be changed since they are stored in the array as references. If parts are added to the array or the sequence is changed, the array needs to be given back to the `Zend_Mime_Part` object by calling `->setParts($partsArray)`.

The function `->isMultiPart()` will return true if more than one part is registered with the `Zend_Mime_Message` object and thus the object would generate a Multipart-Mime-Message when generating the actual output.

### 19.2.4. Boundary handling

`Zend_Mime_Message` usually creates and uses its own `Zend_Mime` Object to generate a boundary. If you need to define the boundary or want to change the behaviour of the `Zend_Mime` object used by `Zend_Mime_Message`, you can instantiate the `Zend_Mime` object yourself and then register it to `Zend_Mime_Message`. Usually you will not need to do this. `->setMime(Zend_Mime $mime)` sets a special instance of `Zend_Mime` to be used by this `Zend_Mime_Message`

`->getMime()` returns the instance of `Zend_Mime` that will be used to render the message when `generateMessage()` is called.

`->generateMessage()` renders the `Zend_Mime_Message` content to a string.

### 19.2.5. parsing a string to create a Zend_Mime_Message object (experimental)

A given MIME compliant message in string form can be used to reconstruct a `Zend_Mime_Message` Object from it. `Zend_Mime_Message` has a static factory Method to parse this String and return a `Zend_Mime_Message` Object.

`Zend_Mime_Message::createFromMessage($str, $boundary)` decodes the given string and returns a `Zend_Mime_Message` Object that can then be examined using `->getParts()`

السابق | أعلى | التالي
فصل 19. Zend_Mime | البداية | 19.3. Zend_Mime_Part