MailMimeParser 3.0

GenericHelper extends AbstractHelper
in package

Provides common Message helper routines for Message manipulation.

Tags
author

Zaahid Bateson

Table of Contents

$mimePartFactory  : IMimePartFactory
$uuEncodedPartFactory  : IUUEncodedPartFactory
$nonMimeContentFields  : array<string|int, mixed>
__construct()  : mixed
copyContentHeadersAndContent()  : static
Copies Content-* headers from the $from header into the $to header. If the Content-Type header isn't defined in $from, defaults to text/plain with utf-8 and quoted-printable as its Content-Transfer-Encoding.
copyHeader()  : static
Copies the passed $header from $from, to $to or sets the header to $default if it doesn't exist in $from.
createNewContentPartFrom()  : IMimePart
Creates a new content part from the passed part, allowing the part to be used for something else (e.g. changing a non-mime message to a multipart mime message).
movePartContentAndChildren()  : static
Copies type headers (Content-Type, Content-Disposition, Content-Transfer-Encoding) from the $from MimePart to $to. Attaches the content resource handle of $from to $to, and loops over child parts, removing them from $from and adding them to $to.
removeContentHeadersAndContent()  : static
Removes Content-* headers from the passed part, then detaches its content stream.
replacePart()  : static
Replaces the $part IMimePart with $replacement.
isMimeContentField()  : bool
Returns true if the passed header's name is a Content-* header other than one defined in the static $nonMimeContentFields

Properties

$nonMimeContentFields

private static array<string|int, mixed> $nonMimeContentFields = ['contentreturn', 'contentidentifier']

non mime content fields that are not related to the content of a part.

Methods

copyContentHeadersAndContent()

Copies Content-* headers from the $from header into the $to header. If the Content-Type header isn't defined in $from, defaults to text/plain with utf-8 and quoted-printable as its Content-Transfer-Encoding.

public copyContentHeadersAndContent(IMimePart $from, IMimePart $to[, bool $move = false ]) : static

An exception is made for the obsolete Content-Return header, which isn't isn't a MIME content field and so isn't copied.

Parameters
$from : IMimePart
$to : IMimePart
$move : bool = false
Return values
static

copyHeader()

Copies the passed $header from $from, to $to or sets the header to $default if it doesn't exist in $from.

public copyHeader(IMimePart $from, IMimePart $to, string $header[, string $default = null ]) : static
Parameters
$from : IMimePart
$to : IMimePart
$header : string
$default : string = null
Return values
static

createNewContentPartFrom()

Creates a new content part from the passed part, allowing the part to be used for something else (e.g. changing a non-mime message to a multipart mime message).

public createNewContentPartFrom(IMimePart $part) : IMimePart
Parameters
$part : IMimePart
Return values
IMimePart

the newly-created IMimePart

movePartContentAndChildren()

Copies type headers (Content-Type, Content-Disposition, Content-Transfer-Encoding) from the $from MimePart to $to. Attaches the content resource handle of $from to $to, and loops over child parts, removing them from $from and adding them to $to.

public movePartContentAndChildren(IMimePart $from, IMimePart $to) : static
Parameters
$from : IMimePart
$to : IMimePart
Return values
static

removeContentHeadersAndContent()

Removes Content-* headers from the passed part, then detaches its content stream.

public removeContentHeadersAndContent(IMimePart $part) : static

An exception is made for the obsolete Content-Return header, which isn't isn't a MIME content field and so isn't removed.

Parameters
$part : IMimePart
Return values
static

replacePart()

Replaces the $part IMimePart with $replacement.

public replacePart(IMessage $message, IMimePart $part, IMimePart $replacement) : static

Essentially removes $part from its parent, and adds $replacement in its same position. If $part is the IMessage, then $part can't be removed and replaced, and instead $replacement's type headers are copied to $message, and any children below $replacement are added directly below $message.

Parameters
$message : IMessage
$part : IMimePart
$replacement : IMimePart
Return values
static

isMimeContentField()

Returns true if the passed header's name is a Content-* header other than one defined in the static $nonMimeContentFields

private isMimeContentField(IHeader $header[, array<string|int, mixed> $exceptions = [] ]) : bool
Parameters
$header : IHeader
$exceptions : array<string|int, mixed> = []
Return values
bool

Search results