示例#1
0
echo "Extract to output\n";
mailparse_msg_extract_part_file($mime, $fp);
echo "Extract and return as string\n";
$result = mailparse_msg_extract_part_file($mime, $fp, null);
echo "-->\n";
echo $result;
echo "\nExtract to open file\n";
$fpdest = tmpfile();
mailparse_msg_extract_part_file($mime, $fp, $fpdest);
echo "\nrewinding\n";
rewind($fpdest);
fpassthru($fpdest);
echo "\nExtract via user function\n";
mailparse_msg_extract_part_file($mime, $fp);
echo "\nExtract whole part to output\n";
mailparse_msg_extract_whole_part_file($mime, $fp);
echo "\nExtract part from string to output\n";
mailparse_msg_extract_part($mime, $text);
fclose($fpdest);
fclose($fp);
$output = ob_get_contents();
ob_end_clean();
VS($output, "Extract to output\n" . "hello, this is some text hello.\n" . "blah blah blah.\n" . "Extract and return as string\n" . "-->\n" . "hello, this is some text hello.\n" . "blah blah blah.\n" . "\n" . "Extract to open file\n" . "\n" . "rewinding\n" . "hello, this is some text hello.\n" . "blah blah blah.\n" . "\n" . "Extract via user function\n" . "hello, this is some text hello.\n" . "blah blah blah.\n" . "\n" . "Extract whole part to output\n" . "To: fred@bloggs.com\n" . "Mime-Version: 1.0\n" . "Content-Type: text/plain\n" . "Subject: A simple MIME message\n" . "\n" . "hello, this is some text hello.\n" . "blah blah blah.\n" . "\n" . "Extract part from string to output\n" . "hello, this is some text hello.\n" . "blah blah blah.\n");
//////////////////////////////////////////////////////////////////////
$msg = "Received: from mail pickup service by hotmail.com with Microsoft\n" . "SMTPSVC;\n" . "Sat, 18 Feb 2006 22:58:14 -0800\n" . "Received: from 66.178.40.49 by BAY116-DAV8.phx.gbl with DAV;\n" . "Sun, 19 Feb 2006 06:58:13 +0000\n" . "\n" . "test";
$mail = mailparse_msg_create();
mailparse_msg_parse($mail, $msg);
$arr = mailparse_msg_get_structure($mail);
foreach ($arr as $first => $second) {
    $section = mailparse_msg_get_part($mail, $second);
    $info = mailparse_msg_get_part_data($section);
示例#2
0
 /**
  * @param string   $filename
  * @param callable $callback
  *
  * @return string
  */
 public function extractWholePartFile(string $filename, callable $callback)
 {
     return mailparse_msg_extract_whole_part_file($this->resource, $filename, $callback);
 }