mini\Mail\MultipartMessage
class
Documentation
Multipart Message
A PSR-7 MessageInterface that contains multiple child MessageInterfaces. When read as a stream, produces RFC 2046 compliant boundary-delimited content.
Accepts any MessageInterface implementation (Guzzle responses, PSR-7 messages, etc.) without requiring special wrapper classes.
Usage:
$message = new MultipartMessage(MultipartType::Mixed,
new Message('text/plain', 'Hello'),
new Message('text/html', '<h1>Hello</h1>'),
$guzzleResponse // Any MessageInterface works
);
// Access parts
$part = $message->getPart(0);
$count = count($message);
foreach ($message as $part) { ... }
// Modify (immutable)
$message = $message->withAddedPart($attachment);
$message = $message->withoutPart(2);
// Filter
$htmlParts = $message->findParts(fn($p) =>
str_starts_with($p->getHeaderLine('Content-Type'), 'text/html')
);
// Stream the body
$body = $message->getBody();
while (!$body->eof()) {
echo $body->read(8192);
}
Inheritance
Implements:
Psr\Http\Message\MessageInterface
Countable
IteratorAggregate
ArrayAccess
Traversable
Properties (5)
string $protocolVersion
array $headers
array $headerCases
array $parts
string $boundary
Methods (34)
Create a multipart message
Generate a unique boundary string
Get all parts
Get a specific part by index
Check if a part exists at the given index
Return instance with part replaced at the specified index
Return instance with an additional part appended
Return instance without the part at the specified index
Find the first part matching the predicate
Find all parts matching the predicate
Return instance with only parts matching the predicate
Return instance without parts matching the predicate
Get the boundary string
Get the multipart subtype (mixed, alternative, related, etc.)
Return instance with a different boundary
Return instance with a different multipart type
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Documentation missing
Get the message body
Return instance with the specified body
Clone handler