MailMimeParser 3.0

MultipartHelper extends AbstractHelper
in package

Provides various routines to manipulate and create multipart messages from an existing message (e.g. to make space for attachments in a message, or to change a simple message to a multipart/alternative one, etc...)

Tags
author

Zaahid Bateson

Table of Contents

$mimePartFactory  : IMimePartFactory
$uuEncodedPartFactory  : IUUEncodedPartFactory
$genericHelper  : GenericHelper
__construct()  : mixed
createAlternativeContentPart()  : IMimePart
Creates a new mime part as a multipart/alternative and assigns the passed $contentPart as a part below it before returning it.
createAndAddPartForAttachment()  : IMessagePart
Creates and adds a IMimePart for the passed content and options as an attachment.
createContentPartForMimeType()  : IMimePart
Creates a new content part for the passed mimeType and charset, making space by creating a multipart/alternative if needed
createMultipartRelatedPartForInlineChildrenOf()  : IMimePart
Creates a multipart/related part out of 'inline' children of $parent and returns it.
enforceMime()  : static
Enforces the message to be a mime message for a non-mime (e.g. uuencoded or unspecified) message. If the message has uuencoded attachments, sets up the message as a multipart/mixed message and creates a separate content part.
findOtherContentPartFor()  : IMimePart
Finds an alternative inline part in the message and returns it if one exists.
getContentPartContainerFromAlternative()  : bool|IMimePart
Searches the passed $alternativePart for a part with the passed mime type and returns its parent.
getUniqueBoundary()  : string
Creates and returns a unique boundary.
moveAllNonMultiPartsToMessageExcept()  : static
Moves all parts under $from into this message except those with a content-type equal to $exceptMimeType. If the message is not a multipart/mixed message, it is set to multipart/mixed first.
removeAllContentPartsByMimeType()  : bool
Removes the content part of the message with the passed mime type. If there is a remaining content part and it is an alternative part of the main message, the content part is moved to the message part.
removeAllContentPartsFromAlternative()  : bool
Removes all parts of $mimeType from $alternativePart.
removePartByMimeType()  : bool
Removes the 'inline' part with the passed contentType, at the given index defaulting to the first
setContentPartForMimeType()  : static
Either creates a mime part or sets the existing mime part with the passed mimeType to $strongOrHandle.
setMessageAsAlternative()  : static
Sets the passed message as multipart/alternative.
setMessageAsMixed()  : static
Sets the passed message as multipart/mixed.
setMimeHeaderBoundaryOnPart()  : static
Creates a unique mime boundary and assigns it to the passed part's Content-Type header with the passed mime type.

Properties

Methods

createAlternativeContentPart()

Creates a new mime part as a multipart/alternative and assigns the passed $contentPart as a part below it before returning it.

public createAlternativeContentPart(IMessage $message, IMessagePart $contentPart) : IMimePart
Parameters
$message : IMessage
$contentPart : IMessagePart
Return values
IMimePart

the alternative part

createAndAddPartForAttachment()

Creates and adds a IMimePart for the passed content and options as an attachment.

public createAndAddPartForAttachment(IMessage $message, string|resource|StreamInterface $resource, string $mimeType, string $disposition[, string|null $filename = null ][, string $encoding = 'base64' ]) : IMessagePart
Parameters
$message : IMessage
$resource : string|resource|StreamInterface
$mimeType : string
$disposition : string
$filename : string|null = null
$encoding : string = 'base64'
Return values
IMessagePart

createContentPartForMimeType()

Creates a new content part for the passed mimeType and charset, making space by creating a multipart/alternative if needed

public createContentPartForMimeType(IMessage $message, string $mimeType, string $charset) : IMimePart
Parameters
$message : IMessage
$mimeType : string
$charset : string
Return values
IMimePart

createMultipartRelatedPartForInlineChildrenOf()

Creates a multipart/related part out of 'inline' children of $parent and returns it.

public createMultipartRelatedPartForInlineChildrenOf(IMimePart $parent) : IMimePart
Parameters
$parent : IMimePart
Return values
IMimePart

enforceMime()

Enforces the message to be a mime message for a non-mime (e.g. uuencoded or unspecified) message. If the message has uuencoded attachments, sets up the message as a multipart/mixed message and creates a separate content part.

public enforceMime(IMessage $message) : static
Parameters
$message : IMessage
Return values
static

findOtherContentPartFor()

Finds an alternative inline part in the message and returns it if one exists.

public findOtherContentPartFor(IMessage $message, string $mimeType) : IMimePart

If the passed $mimeType is text/plain, searches for a text/html part. Otherwise searches for a text/plain part to return.

Parameters
$message : IMessage
$mimeType : string
Return values
IMimePart

or null if not found

getContentPartContainerFromAlternative()

Searches the passed $alternativePart for a part with the passed mime type and returns its parent.

public getContentPartContainerFromAlternative(string $mimeType, IMimePart $alternativePart) : bool|IMimePart

Used for alternative mime types that have a multipart/mixed or multipart/related child containing a content part of $mimeType, where the whole mixed/related part should be removed.

Parameters
$mimeType : string

the content-type to find below $alternativePart

$alternativePart : IMimePart

The multipart/alternative part to look under

Return values
bool|IMimePart

false if a part is not found

getUniqueBoundary()

Creates and returns a unique boundary.

public getUniqueBoundary(string $mimeType) : string
Parameters
$mimeType : string

first 3 characters of a multipart type are used, e.g. REL for relative or ALT for alternative

Return values
string

moveAllNonMultiPartsToMessageExcept()

Moves all parts under $from into this message except those with a content-type equal to $exceptMimeType. If the message is not a multipart/mixed message, it is set to multipart/mixed first.

public moveAllNonMultiPartsToMessageExcept(IMessage $message, IMimePart $from, string $exceptMimeType) : static
Parameters
$message : IMessage
$from : IMimePart
$exceptMimeType : string
Return values
static

removeAllContentPartsByMimeType()

Removes the content part of the message with the passed mime type. If there is a remaining content part and it is an alternative part of the main message, the content part is moved to the message part.

public removeAllContentPartsByMimeType(IMessage $message, string $mimeType[, bool $keepOtherContent = false ]) : bool

If the content part is part of an alternative part beneath the message, the alternative part is replaced by the remaining content part, optionally keeping other parts if $keepOtherContent is set to true.

Parameters
$message : IMessage
$mimeType : string
$keepOtherContent : bool = false
Return values
bool

true on success

removeAllContentPartsFromAlternative()

Removes all parts of $mimeType from $alternativePart.

public removeAllContentPartsFromAlternative(IMessage $message, string $mimeType, IMimePart $alternativePart, bool $keepOtherContent) : bool

If $alternativePart contains a multipart/mixed or multipart/relative part with other parts of different content-types, the multipart part is removed, and parts of different content-types can optionally be moved to the main message part.

Parameters
$message : IMessage
$mimeType : string
$alternativePart : IMimePart
$keepOtherContent : bool
Return values
bool

removePartByMimeType()

Removes the 'inline' part with the passed contentType, at the given index defaulting to the first

public removePartByMimeType(IMessage $message, string $mimeType, int $index) : bool
Parameters
$message : IMessage
$mimeType : string
$index : int
Return values
bool

true on success

setContentPartForMimeType()

Either creates a mime part or sets the existing mime part with the passed mimeType to $strongOrHandle.

public setContentPartForMimeType(IMessage $message, string $mimeType, string|resource $stringOrHandle, string $charset) : static
Parameters
$message : IMessage
$mimeType : string
$stringOrHandle : string|resource
$charset : string
Return values
static

setMessageAsAlternative()

Sets the passed message as multipart/alternative.

public setMessageAsAlternative(IMessage $message) : static

If the message has content, a new part is created and added as a child of the message. The message's content and content headers are moved to the new part.

Parameters
$message : IMessage
Return values
static

setMessageAsMixed()

Sets the passed message as multipart/mixed.

public setMessageAsMixed(IMessage $message) : static

If the message has content, a new part is created and added as a child of the message. The message's content and content headers are moved to the new part.

Parameters
$message : IMessage
Return values
static

setMimeHeaderBoundaryOnPart()

Creates a unique mime boundary and assigns it to the passed part's Content-Type header with the passed mime type.

public setMimeHeaderBoundaryOnPart(IMimePart $part, string $mimeType) : static
Parameters
$part : IMimePart
$mimeType : string
Return values
static

Search results