VERSION
VERSION
Object-oriented representation of a MIME part (RFC 2045-2049).
$defaultCharset : string
The default charset to use when parsing text parts with no charset information.
todo |
Make this a non-static property or pass as parameter to static methods in Horde 6. |
---|
None found |
$parent : \Horde_Mime_Part
Parent object. Value only accurate when iterating.
since |
---|
$_contents : resource
The body of the part. Always stored in binary format.
None found |
$_eol : string
The sequence to use as EOL for this part.
The default is currently to output the EOL sequence internally as
just "\n" instead of the canonical "\r\n" required in RFC 822 & 2045.
To be RFC complaint, the full
None found |
$_headers : \Horde_Mime_Headers
The MIME headers for this part.
None found |
None found |
$_transferEncoding : string
The desired transfer encoding of this part.
None found |
None found |
setDisposition(string $disposition = null)
Set the content-disposition of this part.
string | $disposition | The content-disposition to set ('inline', 'attachment', or an empty value). |
None found |
getDisposition() : string
Get the content-disposition of this part.
The part's content-disposition. An empty string means no desired disposition has been set for this part.
None found |
setDispositionParameter(string $label, string $data)
Add a disposition parameter to this part.
string | $label | The disposition parameter label. |
string | $data | The disposition parameter data. If null, removes the parameter (@since 2.8.0). |
None found |
getDispositionParameter(string $label) : string
Get a disposition parameter from this part.
string | $label | The disposition parameter label. |
The data requested. Returns null if $label is not set.
None found |
getAllDispositionParameters() : array
Get all parameters from the Content-Disposition header.
An array of all the parameters Returns the empty array if no parameters set.
None found |
None found |
getName(boolean $default = false) : string
Get the name of this part.
boolean | $default | If the name parameter doesn't exist, should we use the default name from the description parameter? |
The name of the part.
None found |
setContents(mixed $contents, array $options = array())
Set the body contents of this part.
mixed | $contents | The part body. Either a string or a stream resource, or an array containing both. |
array | $options | Additional options:
|
None found |
appendContents(mixed $contents, $options = array())
Add to the body contents of this part.
mixed | $contents | The part body. Either a string or a stream resource, or an array containing both.
|
$options |
None found |
getContents(array $options = array()) : mixed
Return the body of the part.
array | $options | Additional options:
|
The body text (string) of the part, null if there is no contents, and a stream resource if 'stream' is true.
None found |
setType(string $type)
Set the MIME type of this part.
string | $type | The MIME type to set (ex.: text/plain). |
None found |
getType(boolean $charset = false) : string
Get the full MIME Content-Type of this part.
boolean | $charset | Append character set information to the end of the content type if this is a text/* part? ` |
The MIME type of this part.
None found |
getDefaultType() : string
If the subtype of a MIME part is unrecognized by an application, the default type should be used instead (See RFC 2046). This method returns the default subtype for a particular primary MIME type.
The default MIME type of this part (ex.: text/plain).
None found |
getPrimaryType() : string
Get the primary type of this part.
The primary MIME type of this part.
None found |
getSubType() : string
Get the subtype of this part.
The MIME subtype of this part.
None found |
setCharset(string $charset)
Set the character set of this part.
string | $charset | The character set of this part. |
None found |
getCharset() : string
Get the character set to use for this part.
The character set of this part (lowercase). Returns null if there is no character set.
None found |
setHeaderCharset(string $charset)
Set the character set to use when outputting MIME headers.
string | $charset | The character set. |
None found |
getHeaderCharset() : string
Get the character set to use when outputting MIME headers.
The character set. If no preferred character set has been set, returns null.
None found |
setLanguage(mixed $lang)
Set the language(s) of this part.
mixed | $lang | A language string, or an array of language strings. |
None found |
setDuration(integer $duration)
Set the content duration of the data contained in this part (see RFC 3803).
integer | $duration | The duration of the data, in seconds. If null, clears the duration information. |
None found |
getDuration() : integer
Get the content duration of the data contained in this part (see RFC 3803).
The duration of the data, in seconds. Returns null if there is no duration information.
None found |
setDescription(string $description)
Set the description of this part.
string | $description | The description of this part. If null, deletes the description (@since 2.8.0). |
None found |
getDescription(boolean $default = false) : string
Get the description of this part.
boolean | $default | If the description parameter doesn't exist, should we use the name of the part? |
The description of this part.
None found |
setTransferEncoding(string $encoding, array $options = array())
Set the transfer encoding to use for this part.
Only needed in the following circumstances: 1.) Indicate what the transfer encoding is if the data has not yet been set in the object (can only be set if there presently are not any contents). 2.) Force the encoding to a certain type on a toString() call (if 'send' is true).
string | $encoding | The transfer encoding to use. |
array | $options | Additional options:
|
None found |
getParts() : array
Get a list of all MIME subparts.
An array of the Horde_Mime_Part subparts.
None found |
setContentTypeParameter(string $label, string $data)
Add/remove a content type parameter to this part.
string | $label | The content-type parameter label. |
string | $data | The content-type parameter data. If null, removes the parameter (@since 2.8.0). |
None found |
getContentTypeParameter(string $label) : string
Get a content type parameter from this part.
string | $label | The content type parameter label. |
The data requested. Returns null if $label is not set.
None found |
getAllContentTypeParameters() : array
Get all parameters from the Content-Type header.
An array of all the parameters Returns the empty array if no parameters set.
None found |
setEOL(string $eol)
Sets a new string to use for EOLs.
string | $eol | The string to use for EOLs. |
None found |
getEOL() : string
Get the string to use for EOLs.
The string to use for EOLs.
None found |
addMimeHeaders(array $options = array()) : \Horde_Mime_Headers
Returns a Horde_Mime_Header object containing all MIME headers needed for the part.
array | $options | Additional options:
|
A Horde_Mime_Headers object.
None found |
toString(array $options = array()) : mixed
Return the entire part in MIME format.
array | $options | Additional options:
|
The MIME string (returned as a resource if $stream is true).
None found |
replaceEOL(mixed $text, string $eol = null, boolean $stream = false) : string
Replace newlines in this part's contents with those specified by either the given newline sequence or the part's current EOL setting.
mixed | $text | The text to replace. Either a string or a stream resource. If a stream, and returning a string, will close the stream when done. |
string | $eol | The EOL sequence to use. If not present, uses the part's current EOL setting. |
boolean | $stream | If true, returns a stream resource. |
The text with the newlines replaced by the desired newline sequence (returned as a stream resource if $stream is true).
None found |
getBytes(boolean $approx = false) : integer
Determine the size of this MIME part and its child members.
boolean | $approx | If true, determines an approximate size for parts consisting of base64 encoded data. |
Size of the part, in bytes.
todo |
Remove $approx parameter. |
---|
setBytes(integer $bytes)
Explicitly set the size (in bytes) of this part. This value will only be returned (via getBytes()) if there are no contents currently set.
This function is useful for setting the size of the part when the contents of the part are not fully loaded (i.e. creating a Horde_Mime_Part object from IMAP header information without loading the data of the part).
integer | $bytes | The size of this part in bytes. |
None found |
getSize(boolean $approx = false) : string
Output the size of this MIME part in KB.
boolean | $approx | If true, determines an approximate size for parts consisting of base64 encoded data. |
Size of the part in KB.
todo |
Remove $approx parameter. |
---|
setContentId(string $cid = null) : string
Sets the Content-ID header for this part.
string | $cid | Use this CID (if not already set). Else, generate a random CID. |
The Content-ID for this part.
None found |
getContentId() : string
Returns the Content-ID for this part.
The Content-ID for this part (null if not set).
None found |
setMimeId(string $mimeid)
Alter the MIME ID of this part.
string | $mimeid | The MIME ID. |
None found |
None found |
buildMimeIds(string $id = null, boolean $rfc822 = false)
Build the MIME IDs for this part and all subparts.
string | $id | The ID of this part. |
boolean | $rfc822 | Is this a message/rfc822 part? |
None found |
isBasePart(boolean $base)
Is this the base MIME part?
boolean | $base | True if this is the base MIME part. |
None found |
isAttachment() : boolean
Determines if this MIME part is an attachment for display purposes.
True if this part should be considered an attachment.
since |
Horde_Mime 2.10.0 |
---|
setMetadata(string $key, mixed $data = null)
Set a piece of metadata on this object.
string | $key | The metadata key. |
mixed | $data | The metadata. If null, clears the key. |
None found |
getMetadata(string $key) : mixed
Retrieves metadata from this object.
string | $key | The metadata key. |
The metadata, or null if it doesn't exist.
None found |
send(string $email, \Horde_Mime_Headers $headers, \Horde_Mail_Transport $mailer, array $opts = array())
Sends this message.
string | The address list to send to. |
|
\Horde_Mime_Headers | $headers | The Horde_Mime_Headers object holding this message's headers. |
\Horde_Mail_Transport | $mailer | A Horde_Mail_Transport object. |
array | $opts | Additional options: - broken_rfc2231: (boolean) Attempt to work around non-RFC 2231-compliant MUAs by generating both a RFC 2047-like parameter name and also the correct RFC 2231 parameter (@since 2.5.0). DEFAULT: false - encode: (integer) The encoding to use. A mask of self::ENCODE_* values. DEFAULT: Auto-determined based on transport driver. |
None found |
findBody(string $subtype = null) : mixed
Finds the main "body" text part (if any) in a message.
"Body" data is the first text part under this part.
string | $subtype | Specifically search for this subtype. |
The MIME ID of the main body part, or null if a body part is not found.
None found |
partIterator(boolean $current = true) : \Iterator
Returns the recursive iterator needed to iterate through this part.
boolean | $current | Include the current part as the base? |
Recursive iterator.
since | 2.8.0 |
---|
getPartByIndex( $index) : \Horde_Mime_Part
Returns a subpart by index.
$index |
Part, or null if not found.
None found |
parseMessage(string $text, array $opts = array()) : \Horde_Mime_Part
Attempts to build a Horde_Mime_Part object from message text.
string | $text | The text of the MIME message. |
array | $opts | Additional options:
|
A MIME Part object.
None found |
getRawPartText(mixed $text, string $type, string $id) : string
Attempts to obtain the raw text of a MIME part.
mixed | $text | The full text of the MIME message. The text is assumed to be MIME data (no MIME-Version checking is performed). It can be either a stream or a string. |
string | $type | Either 'header' or 'body'. |
string | $id | The MIME ID. |
The raw text.
None found |
count() : integer
Returns the number of child message parts (doesn't include grandchildren or more remote ancestors).
Number of message parts.
None found |
unserialize(string $data)
Unserialization.
string | $data | Serialized data. |
None found |
None found |
None found |
None found |
None found |
_transferDecode(resource $fp, string $encoding) : resource
Decodes the contents of the part to binary encoding.
resource | $fp | A stream containing the data to decode. |
string | $encoding | The original file encoding. |
A new file resource with the decoded data.
None found |
_transferEncode(resource $fp, string $encoding) : resource
Encodes the contents of the part as necessary for transport.
resource | $fp | A stream containing the data to encode. |
string | $encoding | The encoding to use. |
A new file resource with the encoded data.
None found |
_getTransferEncoding(integer $encode = self::ENCODE_7BIT) : string
Get the transfer encoding for the part based on the user requested transfer encoding and the current contents of the part.
integer | $encode | A mask of allowable encodings. |
The transfer-encoding of this part.
None found |
_reindex(boolean $force = false)
Reindexes the MIME IDs, if necessary.
boolean | $force | Reindex if the current part doesn't have an ID. |
None found |
_writeStream(array $data, array $options = array()) : resource
Write data to a stream.
array | $data | The data to write. Either a stream resource or a string. |
array | $options | Additional options:
|
The stream resource.
None found |
_readStream(resource $fp, boolean $close = false) : string
Read data from a stream.
resource | $fp | An active stream. |
boolean | $close | Close the stream when done reading? |
The data from the stream.
None found |
_scanStream(resource $fp) : mixed
Scans a stream for content type.
resource | $fp | A stream resource. |
Either 'binary', '8bit', or false.
None found |
_getStructure(string $header, string $body, array $opts = array()) : \Horde_Mime_Part
Creates a MIME object from the text of one part of a MIME message.
string | $header | The header text. |
string | $body | The body text. |
array | $opts | Additional options: - ctype: (string) The default content-type. - forcemime: (boolean) If true, the message data is assumed to be MIME data. If not, a MIME-Version header must exist to be parsed as a MIME message. - level: (integer) Current nesting level. - no_body: (boolean) If true, don't set body contents of parts. |
The MIME part object.
None found |
_findHeader(string $text, string $eol) : integer
Find the location of the end of the header text.
string | $text | The text to search. |
string | $eol | The EOL string. |
Header position.
None found |
_findBoundary(string $text, integer $pos, string $boundary, integer $end = null) : array
Find the location of the next boundary string.
string | $text | The text to search. |
integer | $pos | The current position in $text. |
string | $boundary | The boundary string. |
integer | $end | If set, return after matching this many boundaries. |
Keys are the boundary number, values are an array with two elements: 'start' and 'length'.
None found |
_sanityCheckRfc822Attachments()
Re-enocdes message/rfc822 parts in case there was e.g., some broken line length in the headers of the message in the part. Since we shouldn't alter the original message in any way, we simply reset cause the part to be encoded as base64 and sent as a application/octet part.
None found |
_reEncodeMessageAttachment(\Horde_Mime_Part $part)
Rebuilds $part and forces it to be a base64 encoded application/octet-stream part.
\Horde_Mime_Part | $part | The MIME part. |
None found |