PHP Conference Nagoya 2025

mailparse_msg_parse

(PECL mailparse >= 0.9.0)

mailparse_msg_parseIncrementally parse data into buffer

Description

mailparse_msg_parse(resource $mimemail, string $data): bool

Incrementally parse data into the supplied mime mail resource.

This function allow you to stream portions of a file at a time, rather than read and parse the whole thing.

Parameters

mimemail

A valid MIME resource.

data

Note:

The final chunk of data is supposed to end with a newline (CRLF); otherwise the last line of the message will not be parsed.

Return Values

Returns true on success or false on failure.

add a note

User Contributed Notes 1 note

up
1
Adrien
7 years ago
This code written within a function may end up causing a 500 error with php 7 :

$mime = mailparse_msg_create();
mailparse_msg_parse($mime,$content);
exit;

Don't forget to free the ressource using mailparse_msg_free($mime) before the exit, apache/php does not seem to be able to do it automatically.
To Top