MailMimeParser 2.2

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, string>
__construct()  : mixed
copyContentHeadersAndContent()  : mixed
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()  : mixed
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()  : mixed
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()  : mixed
Removes Content-* headers from the passed part, then detaches its content stream.
replacePart()  : mixed
Replaces the $part IMimePart with $replacement.
isMimeContentField()  : mixed
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, string> $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 ]) : mixed

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
mixed

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 ]) : mixed
Parameters
$from : IMimePart
$to : IMimePart
$header : string
$default : string = null
Return values
mixed

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) : mixed
Parameters
$from : IMimePart
$to : IMimePart
Return values
mixed

removeContentHeadersAndContent()

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

public removeContentHeadersAndContent(IMimePart $part) : mixed

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
mixed

replacePart()

Replaces the $part IMimePart with $replacement.

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

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
mixed

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[, string $exceptions = [] ]) : mixed
Parameters
$header : IHeader
$exceptions : string = []
Return values
mixed

Search results