Documentation

Horde_Mime_Part
in package
implements ArrayAccess, Countable, RecursiveIterator, Serializable

Object-oriented representation of a MIME part (RFC 2045-2049).

Tags
author

Chuck Hagenbuch chuck@horde.org

author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

1999-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Interfaces, Classes, Traits and Enums

ArrayAccess
Countable
RecursiveIterator
Serializable

Table of Contents

DEFAULT_ENCODING  = 'binary'
ENCODE_7BIT  = 1
ENCODE_8BIT  = 2
ENCODE_BINARY  = 4
EOL  = "\n"
NESTING_LIMIT  = 100
RFC_EOL  = "\r\n"
STATUS_BASEPART  = 2
STATUS_REINDEX  = 1
UNKNOWN  = 'x-unknown'
VERSION  = 2
$defaultCharset  : string
The default charset to use when parsing text parts with no charset information.
$encodingTypes  : mixed
$memoryLimit  : int
The memory limit for use with the PHP temp stream.
$mimeTypes  : mixed
$parent  : Horde_Mime_Part
Parent object. Value only accurate when iterating.
$_bytes  : int
Default value for this Part's size.
$_contents  : resource
The body of the part. Always stored in binary format.
$_eol  : string
The sequence to use as EOL for this part.
$_failed  : bool
Flag to detect if a message failed to send at least once.
$_hdrCharset  : string
The charset to output the headers in.
$_headers  : Horde_Mime_Headers
The MIME headers for this part.
$_metadata  : array<string|int, mixed>
Metadata.
$_mimeid  : string
The MIME ID of this part.
$_parts  : array<string|int, mixed>
The subparts of this part.
$_status  : int
Status mask for this part.
$_temp  : array<string|int, mixed>
Temporary array.
$_transferEncoding  : string
The desired transfer encoding of this part.
__clone()  : mixed
Function to run on clone.
__construct()  : mixed
Constructor.
__serialize()  : array<string|int, mixed>
__unserialize()  : void
addMimeHeaders()  : Horde_Mime_Headers
Returns a Horde_Mime_Header object containing all MIME headers needed for the part.
addPart()  : mixed
alterPart()  : mixed
appendContents()  : mixed
Add to the body contents of this part.
buildMimeIds()  : mixed
Build the MIME IDs for this part and all subparts.
clearContents()  : mixed
Clears the body contents of this part.
clearContentTypeParameter()  : mixed
contentTypeMap()  : mixed
count()  : int
Returns the number of child message parts (doesn't include grandchildren or more remote ancestors).
current()  : mixed
findBody()  : mixed
Finds the main "body" text part (if any) in a message.
getAllContentTypeParameters()  : array<string|int, mixed>
Get all parameters from the Content-Type header.
getAllDispositionParameters()  : array<string|int, mixed>
Get all parameters from the Content-Disposition header.
getBytes()  : int
Determine the size of this MIME part and its child members.
getCharset()  : string
Get the character set to use for this part.
getChildren()  : mixed
getContentId()  : string
Returns the Content-ID for this part.
getContents()  : mixed
Return the body of the part.
getContentTypeParameter()  : string
Get a content type parameter from this part.
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.
getDescription()  : string
Get the description of this part.
getDisposition()  : string
Get the content-disposition of this part.
getDispositionParameter()  : string
Get a disposition parameter from this part.
getDuration()  : int
Get the content duration of the data contained in this part (see RFC 3803).
getEOL()  : string
Get the string to use for EOLs.
getHeaderCharset()  : string
Get the character set to use when outputting MIME headers.
getLanguage()  : mixed
Get the language(s) of this part.
getMetadata()  : mixed
Retrieves metadata from this object.
getMimeId()  : string
Returns the MIME ID of this part.
getName()  : string
Get the name of this part.
getPart()  : mixed
getPartByIndex()  : Horde_Mime_Part
Returns a subpart by index.
getParts()  : array<string|int, mixed>
Get a list of all MIME subparts.
getPrimaryType()  : string
Get the primary type of this part.
getRawPartText()  : string
Attempts to obtain the raw text of a MIME part.
getSize()  : string
Output the size of this MIME part in KB.
getSubType()  : string
Get the subtype of this part.
getType()  : string
Get the full MIME Content-Type of this part.
hasChildren()  : mixed
isAttachment()  : bool
Determines if this MIME part is an attachment for display purposes.
isBasePart()  : mixed
Is this the base MIME part?
key()  : mixed
next()  : mixed
offsetExists()  : mixed
offsetGet()  : mixed
offsetSet()  : mixed
offsetUnset()  : mixed
parseMessage()  : Horde_Mime_Part
Attempts to build a Horde_Mime_Part object from message text.
partIterator()  : Iterator
Returns the recursive iterator needed to iterate through this part.
removePart()  : mixed
replaceEOL()  : string
Replace newlines in this part's contents with those specified by either the given newline sequence or the part's current EOL setting.
rewind()  : mixed
send()  : mixed
Sends this message.
serialize()  : string
Serialization.
setBytes()  : mixed
Explicitly set the size (in bytes) of this part. This value will only be returned (via getBytes()) if there are no contents currently set.
setCharset()  : mixed
Set the character set of this part.
setContentId()  : string
Sets the Content-ID header for this part.
setContents()  : mixed
Set the body contents of this part.
setContentTypeParameter()  : mixed
Add/remove a content type parameter to this part.
setDescription()  : mixed
Set the description of this part.
setDisposition()  : mixed
Set the content-disposition of this part.
setDispositionParameter()  : mixed
Add a disposition parameter to this part.
setDuration()  : mixed
Set the content duration of the data contained in this part (see RFC 3803).
setEOL()  : mixed
Sets a new string to use for EOLs.
setHeaderCharset()  : mixed
Set the character set to use when outputting MIME headers.
setLanguage()  : mixed
Set the language(s) of this part.
setMetadata()  : mixed
Set a piece of metadata on this object.
setMimeId()  : mixed
Alter the MIME ID of this part.
setName()  : mixed
Set the name of this part.
setTransferEncoding()  : mixed
Set the transfer encoding to use for this part.
setType()  : mixed
Set the MIME type of this part.
toString()  : mixed
Return the entire part in MIME format.
unserialize()  : mixed
Unserialization.
valid()  : mixed
_findBoundary()  : array<string|int, mixed>
Find the location of the next boundary string.
_findHeader()  : int
Find the location of the end of the header text.
_getStructure()  : Horde_Mime_Part
Creates a MIME object from the text of one part of a MIME message.
_getTransferEncoding()  : string
Get the transfer encoding for the part based on the user requested transfer encoding and the current contents of the part.
_readStream()  : string
Read data from a stream.
_reEncodeMessageAttachment()  : mixed
Rebuilds $part and forces it to be a base64 encoded application/octet-stream part.
_reindex()  : mixed
Reindexes the MIME IDs, if necessary.
_sanityCheckRfc822Attachments()  : mixed
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.
_scanStream()  : mixed
Scans a stream for content type.
_transferDecode()  : resource
Decodes the contents of the part to binary encoding.
_transferEncode()  : resource
Encodes the contents of the part as necessary for transport.
_writeStream()  : resource
Write data to a stream.

Constants

DEFAULT_ENCODING

public mixed DEFAULT_ENCODING = 'binary'

ENCODE_7BIT

public mixed ENCODE_7BIT = 1

ENCODE_8BIT

public mixed ENCODE_8BIT = 2

ENCODE_BINARY

public mixed ENCODE_BINARY = 4

EOL

public mixed EOL = "\n"

NESTING_LIMIT

public mixed NESTING_LIMIT = 100

RFC_EOL

public mixed RFC_EOL = "\r\n"

STATUS_BASEPART

public mixed STATUS_BASEPART = 2

STATUS_REINDEX

public mixed STATUS_REINDEX = 1

UNKNOWN

public mixed UNKNOWN = 'x-unknown'
Tags
deprecated

VERSION

public mixed VERSION = 2

Properties

$defaultCharset

The default charset to use when parsing text parts with no charset information.

public static string $defaultCharset = 'us-ascii'
Tags
todo

Make this a non-static property or pass as parameter to static methods in Horde 6.

$encodingTypes

public static mixed $encodingTypes = array( '7bit', '8bit', 'base64', 'binary', 'quoted-printable', // Non-RFC types, but old mailers may still use 'uuencode', 'x-uuencode', 'x-uue', )
Tags
deprecated

$memoryLimit

The memory limit for use with the PHP temp stream.

public static int $memoryLimit = 2097152

$mimeTypes

public static mixed $mimeTypes = array('text', 'multipart', 'message', 'application', 'audio', 'image', 'video', 'model')
Tags
deprecated

$parent

Parent object. Value only accurate when iterating.

public Horde_Mime_Part $parent = \null
Tags
since
2.8.0

$_bytes

Default value for this Part's size.

protected int $_bytes

$_contents

The body of the part. Always stored in binary format.

protected resource $_contents

$_eol

The sequence to use as EOL for this part.

protected string $_eol = self::EOL

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 <CR><LF> EOL combination should be used when sending a message.

$_failed

Flag to detect if a message failed to send at least once.

protected bool $_failed = \false

$_hdrCharset

The charset to output the headers in.

protected string $_hdrCharset = \null

$_metadata

Metadata.

protected array<string|int, mixed> $_metadata = array()

$_mimeid

The MIME ID of this part.

protected string $_mimeid = \null

$_parts

The subparts of this part.

protected array<string|int, mixed> $_parts = array()

$_status

Status mask for this part.

protected int $_status = 0

$_temp

Temporary array.

protected array<string|int, mixed> $_temp = array()

$_transferEncoding

The desired transfer encoding of this part.

protected string $_transferEncoding = self::DEFAULT_ENCODING

Methods

__clone()

Function to run on clone.

public __clone() : mixed
Return values
mixed

__construct()

Constructor.

public __construct() : mixed
Return values
mixed

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

addMimeHeaders()

Returns a Horde_Mime_Header object containing all MIME headers needed for the part.

public addMimeHeaders([array<string|int, mixed> $options = array() ]) : Horde_Mime_Headers
Parameters
$options : array<string|int, mixed> = array()

Additional options:

  • encode: (integer) A mask of allowable encodings. DEFAULT: Auto-determined
  • headers: (Horde_Mime_Headers) The object to add the MIME headers to. DEFAULT: Add headers to a new object
Return values
Horde_Mime_Headers

A Horde_Mime_Headers object.

addPart()

public addPart(mixed $mime_part) : mixed
Parameters
$mime_part : mixed
Tags
deprecated

Use array access instead.

Return values
mixed

alterPart()

public alterPart(mixed $id, mixed $mime_part) : mixed
Parameters
$id : mixed
$mime_part : mixed
Tags
deprecated

Use array access instead.

Return values
mixed

appendContents()

Add to the body contents of this part.

public appendContents(mixed $contents[, mixed $options = array() ]) : mixed
Parameters
$contents : mixed

The part body. Either a string or a stream resource, or an array containing both.

  • encoding: (string) The encoding of $contents. DEFAULT: Current transfer encoding value.
  • usestream: (boolean) If $contents is a stream, should we directly use that stream? DEFAULT: $contents copied to a new stream.
$options : mixed = array()
Return values
mixed

buildMimeIds()

Build the MIME IDs for this part and all subparts.

public buildMimeIds([string $id = null ][, bool $rfc822 = false ]) : mixed
Parameters
$id : string = null

The ID of this part.

$rfc822 : bool = false

Is this a message/rfc822 part?

Return values
mixed

clearContents()

Clears the body contents of this part.

public clearContents() : mixed
Return values
mixed

clearContentTypeParameter()

public clearContentTypeParameter(mixed $label) : mixed
Parameters
$label : mixed
Tags
deprecated

Use setContentTypeParameter with a null $data value.

Return values
mixed

contentTypeMap()

public contentTypeMap([mixed $sort = true ]) : mixed
Parameters
$sort : mixed = true
Tags
deprecated

Use iterator instead.

Return values
mixed

count()

Returns the number of child message parts (doesn't include grandchildren or more remote ancestors).

public count() : int
Return values
int

Number of message parts.

current()

public current() : mixed
Tags
since
2.8.0
Return values
mixed

findBody()

Finds the main "body" text part (if any) in a message.

public findBody([string $subtype = null ]) : mixed

"Body" data is the first text part under this part.

Parameters
$subtype : string = null

Specifically search for this subtype.

Return values
mixed

The MIME ID of the main body part, or null if a body part is not found.

getAllContentTypeParameters()

Get all parameters from the Content-Type header.

public getAllContentTypeParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of all the parameters Returns the empty array if no parameters set.

getAllDispositionParameters()

Get all parameters from the Content-Disposition header.

public getAllDispositionParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of all the parameters Returns the empty array if no parameters set.

getBytes()

Determine the size of this MIME part and its child members.

public getBytes([bool $approx = false ]) : int
Parameters
$approx : bool = false

If true, determines an approximate size for parts consisting of base64 encoded data.

Tags
todo

Remove $approx parameter.

Return values
int

Size of the part, in bytes.

getCharset()

Get the character set to use for this part.

public getCharset() : string
Return values
string

The character set of this part (lowercase). Returns null if there is no character set.

getChildren()

public getChildren() : mixed
Tags
since
2.8.0
Return values
mixed

getContentId()

Returns the Content-ID for this part.

public getContentId() : string
Return values
string

The Content-ID for this part (null if not set).

getContents()

Return the body of the part.

public getContents([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

Additional options:

  • canonical: (boolean) Returns the contents in strict RFC 822 & 2045 output - namely, all newlines end with the canonical <CR><LF> sequence. DEFAULT: No
  • stream: (boolean) Return the body as a stream resource. DEFAULT: No
Return values
mixed

The body text (string) of the part, null if there is no contents, and a stream resource if 'stream' is true.

getContentTypeParameter()

Get a content type parameter from this part.

public getContentTypeParameter(string $label) : string
Parameters
$label : string

The content type parameter label.

Return values
string

The data requested. Returns null if $label is not set.

getDefaultType()

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.

public getDefaultType() : string
Return values
string

The default MIME type of this part (ex.: text/plain).

getDescription()

Get the description of this part.

public getDescription([bool $default = false ]) : string
Parameters
$default : bool = false

If the description parameter doesn't exist, should we use the name of the part?

Return values
string

The description of this part.

getDisposition()

Get the content-disposition of this part.

public getDisposition() : string
Return values
string

The part's content-disposition. An empty string means no desired disposition has been set for this part.

getDispositionParameter()

Get a disposition parameter from this part.

public getDispositionParameter(string $label) : string
Parameters
$label : string

The disposition parameter label.

Return values
string

The data requested. Returns null if $label is not set.

getDuration()

Get the content duration of the data contained in this part (see RFC 3803).

public getDuration() : int
Return values
int

The duration of the data, in seconds. Returns null if there is no duration information.

getEOL()

Get the string to use for EOLs.

public getEOL() : string
Return values
string

The string to use for EOLs.

getHeaderCharset()

Get the character set to use when outputting MIME headers.

public getHeaderCharset() : string
Return values
string

The character set. If no preferred character set has been set, returns null.

getLanguage()

Get the language(s) of this part.

public getLanguage() : mixed
Return values
mixed

getMetadata()

Retrieves metadata from this object.

public getMetadata(string $key) : mixed
Parameters
$key : string

The metadata key.

Return values
mixed

The metadata, or null if it doesn't exist.

getMimeId()

Returns the MIME ID of this part.

public getMimeId() : string
Return values
string

The MIME ID.

getName()

Get the name of this part.

public getName([bool $default = false ]) : string
Parameters
$default : bool = false

If the name parameter doesn't exist, should we use the default name from the description parameter?

Return values
string

The name of the part.

getPart()

public getPart(mixed $id) : mixed
Parameters
$id : mixed
Tags
deprecated

Use array access instead.

Return values
mixed

getPartByIndex()

Returns a subpart by index.

public getPartByIndex(mixed $index) : Horde_Mime_Part
Parameters
$index : mixed
Return values
Horde_Mime_Part

Part, or null if not found.

getParts()

Get a list of all MIME subparts.

public getParts() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of the Horde_Mime_Part subparts.

getPrimaryType()

Get the primary type of this part.

public getPrimaryType() : string
Return values
string

The primary MIME type of this part.

getRawPartText()

Attempts to obtain the raw text of a MIME part.

public static getRawPartText(mixed $text, string $type, string $id) : string
Parameters
$text : mixed

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.

$type : string

Either 'header' or 'body'.

$id : string

The MIME ID.

Tags
throws
Horde_Mime_Exception
Return values
string

The raw text.

getSize()

Output the size of this MIME part in KB.

public getSize([bool $approx = false ]) : string
Parameters
$approx : bool = false

If true, determines an approximate size for parts consisting of base64 encoded data.

Tags
todo

Remove $approx parameter.

Return values
string

Size of the part in KB.

getSubType()

Get the subtype of this part.

public getSubType() : string
Return values
string

The MIME subtype of this part.

getType()

Get the full MIME Content-Type of this part.

public getType([bool $charset = false ]) : string
Parameters
$charset : bool = false

Append character set information to the end of the content type if this is a text/* part? `

Return values
string

The MIME type of this part.

hasChildren()

public hasChildren() : mixed
Tags
since
2.8.0
Return values
mixed

isAttachment()

Determines if this MIME part is an attachment for display purposes.

public isAttachment() : bool
Tags
since

Horde_Mime 2.10.0

Return values
bool

True if this part should be considered an attachment.

isBasePart()

Is this the base MIME part?

public isBasePart(bool $base) : mixed
Parameters
$base : bool

True if this is the base MIME part.

Return values
mixed

key()

public key() : mixed
Tags
since
2.8.0
Return values
mixed

next()

public next() : mixed
Tags
since
2.8.0
Return values
mixed

offsetExists()

public offsetExists(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

offsetSet()

public offsetSet(mixed $offset, mixed $value) : mixed
Parameters
$offset : mixed
$value : mixed
Return values
mixed

offsetUnset()

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

parseMessage()

Attempts to build a Horde_Mime_Part object from message text.

public static parseMessage(string $text[, array<string|int, mixed> $opts = array() ]) : Horde_Mime_Part
Parameters
$text : string

The text of the MIME message.

$opts : array<string|int, mixed> = array()

Additional options:

  • forcemime: (boolean) If true, the message data is assumed to be MIME data. If not, a MIME-Version header must exist (RFC 2045 [4]) to be parsed as a MIME message. DEFAULT: false
  • level: (integer) Current nesting level of the MIME data. DEFAULT: 0
  • no_body: (boolean) If true, don't set body contents of parts (since 2.2.0). DEFAULT: false
Tags
throws
Horde_Mime_Exception
Return values
Horde_Mime_Part

A MIME Part object.

partIterator()

Returns the recursive iterator needed to iterate through this part.

public partIterator([bool $current = true ]) : Iterator
Parameters
$current : bool = true

Include the current part as the base?

Tags
since
2.8.0
Return values
Iterator

Recursive iterator.

removePart()

public removePart(mixed $id) : mixed
Parameters
$id : mixed
Tags
deprecated

Use array access instead.

Return values
mixed

replaceEOL()

Replace newlines in this part's contents with those specified by either the given newline sequence or the part's current EOL setting.

public replaceEOL(mixed $text[, string $eol = null ][, bool $stream = false ]) : string
Parameters
$text : mixed

The text to replace. Either a string or a stream resource. If a stream, and returning a string, will close the stream when done.

$eol : string = null

The EOL sequence to use. If not present, uses the part's current EOL setting.

$stream : bool = false

If true, returns a stream resource.

Return values
string

The text with the newlines replaced by the desired newline sequence (returned as a stream resource if $stream is true).

rewind()

public rewind() : mixed
Tags
since
2.8.0
Return values
mixed

send()

Sends this message.

public send(string $email, Horde_Mime_Headers $headers, Horde_Mail_Transport $mailer[, array<string|int, mixed> $opts = array() ]) : mixed
Parameters
$email : string

The address list to send to.

$headers : Horde_Mime_Headers

The Horde_Mime_Headers object holding this message's headers.

$mailer : Horde_Mail_Transport

A Horde_Mail_Transport object.

$opts : array<string|int, mixed> = array()

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.
Tags
throws
Horde_Mime_Exception
throws
InvalidArgumentException
Return values
mixed

serialize()

Serialization.

public serialize() : string
Return values
string

Serialized data.

setBytes()

Explicitly set the size (in bytes) of this part. This value will only be returned (via getBytes()) if there are no contents currently set.

public setBytes(int $bytes) : mixed

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).

Parameters
$bytes : int

The size of this part in bytes.

Return values
mixed

setCharset()

Set the character set of this part.

public setCharset(string $charset) : mixed
Parameters
$charset : string

The character set of this part.

Return values
mixed

setContentId()

Sets the Content-ID header for this part.

public setContentId([string $cid = null ]) : string
Parameters
$cid : string = null

Use this CID (if not already set). Else, generate a random CID.

Return values
string

The Content-ID for this part.

setContents()

Set the body contents of this part.

public setContents(mixed $contents[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$contents : mixed

The part body. Either a string or a stream resource, or an array containing both.

$options : array<string|int, mixed> = array()

Additional options:

  • encoding: (string) The encoding of $contents. DEFAULT: Current transfer encoding value.
  • usestream: (boolean) If $contents is a stream, should we directly use that stream? DEFAULT: $contents copied to a new stream.
Return values
mixed

setContentTypeParameter()

Add/remove a content type parameter to this part.

public setContentTypeParameter(string $label, string $data) : mixed
Parameters
$label : string

The content-type parameter label.

$data : string

The content-type parameter data. If null, removes the parameter (@since 2.8.0).

Return values
mixed

setDescription()

Set the description of this part.

public setDescription(string $description) : mixed
Parameters
$description : string

The description of this part. If null, deletes the description (@since 2.8.0).

Return values
mixed

setDisposition()

Set the content-disposition of this part.

public setDisposition([string $disposition = null ]) : mixed
Parameters
$disposition : string = null

The content-disposition to set ('inline', 'attachment', or an empty value).

Return values
mixed

setDispositionParameter()

Add a disposition parameter to this part.

public setDispositionParameter(string $label, string $data) : mixed
Parameters
$label : string

The disposition parameter label.

$data : string

The disposition parameter data. If null, removes the parameter (@since 2.8.0).

Return values
mixed

setDuration()

Set the content duration of the data contained in this part (see RFC 3803).

public setDuration(int $duration) : mixed
Parameters
$duration : int

The duration of the data, in seconds. If null, clears the duration information.

Return values
mixed

setEOL()

Sets a new string to use for EOLs.

public setEOL(string $eol) : mixed
Parameters
$eol : string

The string to use for EOLs.

Return values
mixed

setHeaderCharset()

Set the character set to use when outputting MIME headers.

public setHeaderCharset(string $charset) : mixed
Parameters
$charset : string

The character set.

Return values
mixed

setLanguage()

Set the language(s) of this part.

public setLanguage(mixed $lang) : mixed
Parameters
$lang : mixed

A language string, or an array of language strings.

Return values
mixed

setMetadata()

Set a piece of metadata on this object.

public setMetadata(string $key[, mixed $data = null ]) : mixed
Parameters
$key : string

The metadata key.

$data : mixed = null

The metadata. If null, clears the key.

Return values
mixed

setMimeId()

Alter the MIME ID of this part.

public setMimeId(string $mimeid) : mixed
Parameters
$mimeid : string

The MIME ID.

Return values
mixed

setName()

Set the name of this part.

public setName(string $name) : mixed
Parameters
$name : string

The name to set.

Return values
mixed

setTransferEncoding()

Set the transfer encoding to use for this part.

public setTransferEncoding(string $encoding[, array<string|int, mixed> $options = array() ]) : mixed

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).

Parameters
$encoding : string

The transfer encoding to use.

$options : array<string|int, mixed> = array()

Additional options:

  • send: (boolean) If true, use $encoding as the sending encoding. DEFAULT: $encoding is used to change the base encoding.
Return values
mixed

setType()

Set the MIME type of this part.

public setType(string $type) : mixed
Parameters
$type : string

The MIME type to set (ex.: text/plain).

Return values
mixed

toString()

Return the entire part in MIME format.

public toString([array<string|int, mixed> $options = array() ]) : mixed
Parameters
$options : array<string|int, mixed> = array()

Additional options:

  • canonical: (boolean) Returns the encoded part in strict RFC 822 & 2045 output - namely, all newlines end with the canonical <CR><LF> sequence. DEFAULT: false
  • defserver: (string) The default server to use when creating the header string. DEFAULT: none
  • encode: (integer) A mask of allowable encodings. DEFAULT: self::ENCODE_7BIT
  • headers: (mixed) Include the MIME headers? If true, create a new headers object. If a Horde_Mime_Headers object, add MIME headers to this object. If a string, use the string verbatim. DEFAULT: true
  • id: (string) Return only this MIME ID part. DEFAULT: Returns the base part.
  • stream: (boolean) Return a stream resource. DEFAULT: false
Return values
mixed

The MIME string (returned as a resource if $stream is true).

unserialize()

Unserialization.

public unserialize(string $data) : mixed
Parameters
$data : string

Serialized data.

Tags
throws
Exception
Return values
mixed

valid()

public valid() : mixed
Tags
since
2.8.0
Return values
mixed

_findBoundary()

Find the location of the next boundary string.

protected static _findBoundary(string $text, int $pos, string $boundary[, int $end = null ]) : array<string|int, mixed>
Parameters
$text : string

The text to search.

$pos : int

The current position in $text.

$boundary : string

The boundary string.

$end : int = null

If set, return after matching this many boundaries.

Return values
array<string|int, mixed>

Keys are the boundary number, values are an array with two elements: 'start' and 'length'.

_findHeader()

Find the location of the end of the header text.

protected static _findHeader(string $text, string $eol) : int
Parameters
$text : string

The text to search.

$eol : string

The EOL string.

Return values
int

Header position.

_getStructure()

Creates a MIME object from the text of one part of a MIME message.

protected static _getStructure(string $header, string $body[, array<string|int, mixed> $opts = array() ]) : Horde_Mime_Part
Parameters
$header : string

The header text.

$body : string

The body text.

$opts : array<string|int, mixed> = array()

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.
Return values
Horde_Mime_Part

The MIME part object.

_getTransferEncoding()

Get the transfer encoding for the part based on the user requested transfer encoding and the current contents of the part.

protected _getTransferEncoding([int $encode = self::ENCODE_7BIT ]) : string
Parameters
$encode : int = self::ENCODE_7BIT

A mask of allowable encodings.

Return values
string

The transfer-encoding of this part.

_readStream()

Read data from a stream.

protected _readStream(resource $fp[, bool $close = false ]) : string
Parameters
$fp : resource

An active stream.

$close : bool = false

Close the stream when done reading?

Return values
string

The data from the stream.

_reEncodeMessageAttachment()

Rebuilds $part and forces it to be a base64 encoded application/octet-stream part.

protected _reEncodeMessageAttachment(Horde_Mime_Part $part) : mixed
Parameters
$part : Horde_Mime_Part

The MIME part.

Return values
mixed

_reindex()

Reindexes the MIME IDs, if necessary.

protected _reindex([bool $force = false ]) : mixed
Parameters
$force : bool = false

Reindex if the current part doesn't have an ID.

Return values
mixed

_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.

protected _sanityCheckRfc822Attachments() : mixed
Return values
mixed

_scanStream()

Scans a stream for content type.

protected _scanStream(resource $fp) : mixed
Parameters
$fp : resource

A stream resource.

Return values
mixed

Either 'binary', '8bit', or false.

_transferDecode()

Decodes the contents of the part to binary encoding.

protected _transferDecode(resource $fp, string $encoding) : resource
Parameters
$fp : resource

A stream containing the data to decode.

$encoding : string

The original file encoding.

Return values
resource

A new file resource with the decoded data.

_transferEncode()

Encodes the contents of the part as necessary for transport.

protected _transferEncode(resource $fp, string $encoding) : resource
Parameters
$fp : resource

A stream containing the data to encode.

$encoding : string

The encoding to use.

Return values
resource

A new file resource with the encoded data.

_writeStream()

Write data to a stream.

protected _writeStream(array<string|int, mixed> $data[, array<string|int, mixed> $options = array() ]) : resource
Parameters
$data : array<string|int, mixed>

The data to write. Either a stream resource or a string.

$options : array<string|int, mixed> = array()

Additional options:

  • error: (boolean) Catch errors when writing to the stream. Throw an ErrorException if an error is found. DEFAULT: false
  • filter: (array) Filter(s) to apply to the string. Keys are the filter names, values are filter params.
  • fp: (resource) Use this stream instead of creating a new one.
Tags
throws
ErrorException
Return values
resource

The stream resource.

Search results