Skip to content

MIME

phil/bounce-parser

Mime\MimeParser::parse(string $raw): Mime\Part reads an Internet message (RFC 5322) and its MIME structure (RFC 2045, RFC 2046). It never throws: what it cannot read is kept as text.

ReadHow
Header fieldsUnfolded and trimmed, names compared without case; a line without a colon, or a name with a space, is skipped
Encoded words (RFC 2047)Decoded to UTF-8 by Headers::decoded(), on request
Media typeIn lowercase, text/plain when missing or malformed (message/rfc822 inside a digest), parameters by lowercase name, quoted values unescaped
Transfer encodingsbase64 (characters outside its alphabet ignored, an impossible length gives nothing) and quoted-printable undone
MultipartsSplit at their boundary lines, preamble and epilogue dropped; a missing closing line ends the multipart with the text
Held messagesmessage/rfc822 and message/global read as the message they hold, in Part::$message

A part that starts with an empty line has no header fields.

Parts

MemberHolds
headersThe Mime\Headers: get(), all(), has(), decoded(), fields
type, parametersThe media type and its parameters
bodyThe body, its transfer encoding undone, in its own character set
partsThe child parts of a multipart
messageThe message a message/rfc822 holds
walk(bool $intoMessages = false)This part and every part under it, depth first
find(string $type)The first part of a media type, without entering held messages

Limits

Limits bounds the work on one message, whatever it holds:

LimitDefaultBeyond it
maxBytes1 MiBNot read: a report puts what matters first, the original message last
maxDepth8A multipart is not split, a held message not read
maxParts64No more part is read
maxHeaders500No more field of a part is read
maxText64 KiBThe text a rule or the reading of a text bounce looks at is cut

Each limit is at least 1, else Exception\InvalidLimits.