MailMimeParser 2.4

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()  : mixed
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()  : 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()  : 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()  : self
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()  : self
Either creates a mime part or sets the existing mime part with the passed mimeType to $strongOrHandle.
setMessageAsAlternative()  : self
Sets the passed message as multipart/alternative.
setMessageAsMixed()  : self
Sets the passed message as multipart/mixed.
setMimeHeaderBoundaryOnPart()  : self
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' ]) : mixed
Parameters
$message : IMessage
$resource : string|resource|StreamInterface
$mimeType : string
$disposition : string
$filename : string|null = null
$encoding : string = 'base64'
Return values
mixed

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

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) : self
Parameters
$message : IMessage
$from : IMimePart
$exceptMimeType : string
Return values
self

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) : self
Parameters
$message : IMessage
$mimeType : string
$stringOrHandle : string|resource
$charset : string
Return values
self

setMessageAsAlternative()

Sets the passed message as multipart/alternative.

public setMessageAsAlternative(IMessage $message) : self

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
self

setMessageAsMixed()

Sets the passed message as multipart/mixed.

public setMessageAsMixed(IMessage $message) : self

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
self

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) : self
Parameters
$part : IMimePart
$mimeType : string
Return values
self

Search results