note 64063 added to function.mailparse-msg-extract-part
| From: | steve at tequilasolutions dot com | Date: | Thu, 06 Apr 2006 17:36:14 +0000 |
| Subject: | note 64063 added to function.mailparse-msg-extract-part | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107462@lists.php.net to get a copy of this message | ||
Unless I've missed something obvious:
get_structure returns array(1,1.1,1.1.2) etc but its not easy to get the contents of each part as
mailparse_msg_extract_part() and mailparse_msg_extract_part_file() just return the lot. However
get_part_data will return the string offsets so you know where to chop the message so you can get
the contents of the parts.
Only issue is get_part_data returns:
[starting-pos] => 0
[starting-pos-body] => 1412
[ending-pos] => 14989
[ending-pos-body] => 14989
Unless I'm missed something else, theres a bug here as ending-pos is the same as
ending-pos-body so it won't chop the contents cleanly, leaving the:
------=_NextPart_000_0069_01C659A6.9072E590--
...as supposedly part of the section contents.
$file = "..../mail"; // path of your mail
$file_txt = implode("",file($file));
$parse = mailparse_msg_parse_file($file);
$structure = mailparse_msg_get_structure($parse);
// chop message parts into array
$parts = array();
foreach ($structure as $s){
print "Part $s\n";
print "--------------------------------------\n";
$part = mailparse_msg_get_part($parse, $s);
$part_data = mailparse_msg_get_part_data($part);
print_r($part_data);
$starting_pos_body = $part_data['starting-pos-body'];
$ending_pos_body = $part_data['ending-pos-body'];
$parts[$s] = substr($file_txt,$starting_pos_body,$ending_pos_body); // copy data into array
print "[".$parts[$s]."]";
print "\n------------------------------------\n";
}
----
Server IP: 85.116.0.130
Probable Submitter: 82.32.72.19
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mailparse-msg-extract-part.php
Edit -- http://master.php.net/note/edit/64063
Del: integrated -- http://master.php.net/note/delete/64063/integrated
Del: useless -- http://master.php.net/note/delete/64063/useless
Del: bad code -- http://master.php.net/note/delete/64063/bad+code
Del: spam -- http://master.php.net/note/delete/64063/spam
Del: non-english -- http://master.php.net/note/delete/64063/non-english
Del: in docs -- http://master.php.net/note/delete/64063/in+docs
Del: other reasons-- http://master.php.net/note/delete/64063
Reject -- http://master.php.net/note/reject/64063
Search -- http://master.php.net/manage/user-notes.php