note 72135 added to function.mailparse-msg-extract-part

From: Date: Thu, 04 Jan 2007 08:12:56 +0000
Subject: note 72135 added to function.mailparse-msg-extract-part
Groups: php.notes 
Request: Send a blank email to php-notes+get-121270@lists.php.net to get a copy of this message
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. ---- Server IP: 66.163.161.117 Probable Submitter: 69.203.116.101 ---- Manual Page -- http://www.php.net/manual/en/function.mailparse-msg-extract-part.php Edit -- https://master.php.net/note/edit/72135 Del: integrated -- https://master.php.net/note/delete/72135/integrated Del: useless -- https://master.php.net/note/delete/72135/useless Del: bad code -- https://master.php.net/note/delete/72135/bad+code Del: spam -- https://master.php.net/note/delete/72135/spam Del: non-english -- https://master.php.net/note/delete/72135/non-english Del: in docs -- https://master.php.net/note/delete/72135/in+docs Del: other reasons-- https://master.php.net/note/delete/72135 Reject -- https://master.php.net/note/reject/72135 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#121270) next »