MailMimeParser 1.1

MultipartHelper extends AbstractHelper

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  : MimePartFactory
$partBuilderFactory  : PartBuilderFactory
$uuEncodedPartFactory  : UUEncodedPartFactory
$genericHelper  : GenericHelper
__construct()  : mixed
Constructor
createAlternativeContentPart()  : MimePart
Creates a new mime part as a multipart/alternative and assigns the passed $contentPart as a part below it before returning it.
createAndAddPartForAttachment()  : MimePart
Creates and adds a MimePart for the passed content and options as an attachment.
createContentPartForMimeType()  : MimePart
Creates a new content part for the passed mimeType and charset, making space by creating a multipart/alternative if needed
createMultipartRelatedPartForInlineChildrenOf()  : MimePart
Creates a multipart/related part out of 'inline' children of $parent and returns it.
enforceMime()  : mixed
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()  : MimeType
Finds an alternative inline part in the message and returns it if one exists.
getContentPartContainerFromAlternative()  : bool|MimePart
Searches the passed $alternativePart for a part with the passed mime type and returns its parent.
getUniqueBoundary()  : string
Creates and returns a unique boundary.
moveAllPartsAsAttachmentsExcept()  : mixed
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()  : mixed
Either creates a mime part or sets the existing mime part with the passed mimeType to $strongOrHandle.
setMessageAsAlternative()  : mixed
Sets the passed message as multipart/alternative.
setMessageAsMixed()  : mixed
Sets the passed message as multipart/mixed.
setMimeHeaderBoundaryOnPart()  : mixed
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(Message $message, MessagePart $contentPart) : MimePart
Parameters
$message : Message
$contentPart : MessagePart
Return values
MimePart

the alternative part

createAndAddPartForAttachment()

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

public createAndAddPartForAttachment(Message $message, string|resource|StreamInterface $resource, string $mimeType, string $disposition[, string $filename = null ]) : MimePart
Parameters
$message : Message
$resource : string|resource|StreamInterface
$mimeType : string
$disposition : string
$filename : string = null
Return values
MimePart

createContentPartForMimeType()

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

public createContentPartForMimeType(Message $message, string $mimeType, string $charset) : MimePart
Parameters
$message : Message
$mimeType : string
$charset : string
Return values
MimePart

createMultipartRelatedPartForInlineChildrenOf()

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

public createMultipartRelatedPartForInlineChildrenOf(ParentHeaderPart $parent) : MimePart
Parameters
$parent : ParentHeaderPart
Return values
MimePart

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(Message $message) : mixed
Parameters
$message : Message
Return values
mixed

findOtherContentPartFor()

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

public findOtherContentPartFor(Message $message, string $mimeType) : MimeType

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

Parameters
$message : Message
$mimeType : string
Return values
MimeType

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, ParentHeaderPart $alternativePart) : bool|MimePart

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 : ParentHeaderPart

The multipart/alternative part to look under

Return values
bool|MimePart

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

moveAllPartsAsAttachmentsExcept()

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 moveAllPartsAsAttachmentsExcept(Message $message, ParentHeaderPart $from, string $exceptMimeType) : mixed
Parameters
$message : Message
$from : ParentHeaderPart
$exceptMimeType : string
Return values
mixed

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(Message $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 : Message
$mimeType : string
$keepOtherContent : bool = false
Return values
bool

true on success

removeAllContentPartsFromAlternative()

Removes all parts of $mimeType from $alternativePart.

public removeAllContentPartsFromAlternative(Message $message, string $mimeType, ParentHeaderPart $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 : Message
$mimeType : string
$alternativePart : ParentHeaderPart
$keepOtherContent : bool
Return values
bool

removePartByMimeType()

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

public removePartByMimeType(Message $message, string $mimeType, int $index) : bool
Parameters
$message : Message
$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(Message $message, string $mimeType, string|resource $stringOrHandle, string $charset) : mixed
Parameters
$message : Message
$mimeType : string
$stringOrHandle : string|resource
$charset : string
Return values
mixed

setMessageAsAlternative()

Sets the passed message as multipart/alternative.

public setMessageAsAlternative(Message $message) : mixed

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 : Message
Return values
mixed

setMessageAsMixed()

Sets the passed message as multipart/mixed.

public setMessageAsMixed(Message $message) : mixed

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 : Message
Return values
mixed

setMimeHeaderBoundaryOnPart()

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

public setMimeHeaderBoundaryOnPart(ParentHeaderPart $part, string $mimeType) : mixed
Parameters
$part : ParentHeaderPart
$mimeType : string
Return values
mixed

Search results