update page now

Voting

: five minus five?
(Example: nine)

The Note You're Voting On

Will
19 years ago
In mailparse version 2.1.1 (and perhaps earlier), when using mailparse_msg_extract_part() with a callback function, it breaks the data it passes to it into 4kB chunks and calls the callback function for each chunk.  So, for example, if it's extracting a 41kB MIME part, the callback function you define will be called 11 times, each time with the next chunk of data.  Here's some quick-and-dirty code that shows one way to handle this:

<?php
    $message = file_get_contents ("email.txt"); // Pull in the e-mail.

    function catch_part ($part)
    {
        $GLOBALS["part_data"] .= $part; // Append the data onto any previously extracted data.
    }

    mailparse_msg_extract_part ("1.1", $message, "catch_part"); // Extract MIME part 1.1
    echo $GLOBALS["part_data"]; // Print out the extracted part.
?>

There's probably a much better way of dealing with this, but hey.  It's what I got.

<< Back to user notes page

To Top