MailMimeParser 0.4

MessageWriter extends MimePartWriter

Writes out a message in a mail-compliant format.

Provides a way of writing out a ZBateson\MailMimeParser\Message object to a resource handle.

Tags
author

Zaahid Bateson

Table of Contents

$defaultStreamFilterParams  : array<string|int, mixed>
$typeToEncodingMap  : array<string|int, mixed>
getInstance()  : mixed
Returns the singleton instance for the class, instantiating it if not already created.
getSignableBody()  : string
Returns the content part of a signed message for a signature to be calculated on the message.
writeMessageTo()  : mixed
Saves the message as a MIME message to the passed resource handle.
writePartContentTo()  : mixed
Writes out the content portion of the mime part based on the headers that are set on the part, taking care of character/content-transfer encoding.
writePartHeadersTo()  : mixed
Writes out the headers of the passed MimePart and follows them with an empty line.
writePartTo()  : mixed
Writes out the MimePart to the passed resource.
recursiveWriteParts()  : bool
Writes out headers and content for the passed MimePart, then loops over its child parts calling recursiveWriteParts on each part.
writeBoundary()  : mixed
Writes out a mime boundary to the passed $handle optionally writing out a number of empty lines before it.
copyContentStream()  : mixed
Copies the content of the $fromHandle stream into the $toHandle stream, maintaining the current read position in $fromHandle. The passed MimePart is where $fromHandle originated after setting up filters on $fromHandle.
setCharsetStreamFilterOnPartStream()  : resource
Sets up a mailmimeparser-encode stream filter on the content resource handle of the passed MimePart if applicable and returns a reference to the filter.
setTransferEncodingFilterOnStream()  : resource
Appends a stream filter on the passed MimePart's content resource handle based on the type of encoding for the passed part.
trimTextBeforeCopying()  : mixed
Trims out any starting and ending CRLF characters in the stream.

Properties

$defaultStreamFilterParams

private static array<string|int, mixed> $defaultStreamFilterParams = ['line-length' => 76, 'line-break-chars' => " "]

$typeToEncodingMap

private static array<string|int, mixed> $typeToEncodingMap = ['quoted-printable' => 'mmp-convert.quoted-printable-encode', 'base64' => 'mmp-convert.base64-encode', 'x-uuencode' => 'mailmimeparser-uuencode', 'x-uue' => 'mailmimeparser-uuencode', 'uuencode' => 'mailmimeparser-uuencode', 'uue' => 'mailmimeparser-uuencode']

Methods

getInstance()

Returns the singleton instance for the class, instantiating it if not already created.

public static getInstance() : mixed
Return values
mixed

getSignableBody()

Returns the content part of a signed message for a signature to be calculated on the message.

public getSignableBody(Message $message) : string
Parameters
$message : Message
Return values
string

writeMessageTo()

Saves the message as a MIME message to the passed resource handle.

public writeMessageTo(Message $message, resource $handle) : mixed
Parameters
$message : Message
$handle : resource
Return values
mixed

writePartContentTo()

Writes out the content portion of the mime part based on the headers that are set on the part, taking care of character/content-transfer encoding.

public writePartContentTo(MimePart $part, resource $handle) : mixed
Parameters
$part : MimePart
$handle : resource
Return values
mixed

writePartHeadersTo()

Writes out the headers of the passed MimePart and follows them with an empty line.

public writePartHeadersTo(MimePart $part, resource $handle) : mixed
Parameters
$part : MimePart
$handle : resource
Return values
mixed

writePartTo()

Writes out the MimePart to the passed resource.

public writePartTo(MimePart $part, resource $handle) : mixed

Takes care of character and content transfer encoding on the output based on what headers are set.

Parameters
$part : MimePart
$handle : resource
Return values
mixed

recursiveWriteParts()

Writes out headers and content for the passed MimePart, then loops over its child parts calling recursiveWriteParts on each part.

protected recursiveWriteParts(MimePart $part, resource $handle) : bool
Parameters
$part : MimePart

the current part to write out

$handle : resource

the handle to write out to

Return values
bool

true if the part had children (and ended with writing a boundary)

writeBoundary()

Writes out a mime boundary to the passed $handle optionally writing out a number of empty lines before it.

protected writeBoundary(resource $handle, string $boundary, int $numLinesBefore, bool $isEnd) : mixed
Parameters
$handle : resource
$boundary : string
$numLinesBefore : int
$isEnd : bool
Return values
mixed

copyContentStream()

Copies the content of the $fromHandle stream into the $toHandle stream, maintaining the current read position in $fromHandle. The passed MimePart is where $fromHandle originated after setting up filters on $fromHandle.

private copyContentStream(MimePart $part, resource $fromHandle, resource $toHandle) : mixed
Parameters
$part : MimePart
$fromHandle : resource
$toHandle : resource
Return values
mixed

setCharsetStreamFilterOnPartStream()

Sets up a mailmimeparser-encode stream filter on the content resource handle of the passed MimePart if applicable and returns a reference to the filter.

private setCharsetStreamFilterOnPartStream(MimePart $part) : resource
Parameters
$part : MimePart
Return values
resource

a reference to the appended stream filter or null

setTransferEncodingFilterOnStream()

Appends a stream filter on the passed MimePart's content resource handle based on the type of encoding for the passed part.

private setTransferEncodingFilterOnStream(MimePart $part, resource $handle, StreamLeftover $leftovers) : resource
Parameters
$part : MimePart
$handle : resource
$leftovers : StreamLeftover
Return values
resource

the stream filter

trimTextBeforeCopying()

Trims out any starting and ending CRLF characters in the stream.

private trimTextBeforeCopying(string &$read, bool &$first, string &$lastChars) : mixed
Parameters
$read : string

the read string, and where the result will be written to

$first : bool

set to true if this is the first set of read characters from the stream (ltrims CRLF)

$lastChars : string

contains any CRLF characters from the last $read line if it ended with a CRLF (because they're trimmed from the end, and get prepended to $read).

Return values
mixed

Search results