Пример #1
0
 /**
  * @param resource $srcFilePointer  A valid file handle. The file is streamed through the parser.
  * @param resource $destFilePointer The destination file handle in which the encoded data will be written.
  * @param string   $encoding        One of the character encodings supported by the mbstring module.
  *
  * @return bool Returns TRUE on success or FALSE on failure.
  */
 public static function encodeStream($srcFilePointer, $destFilePointer, string $encoding)
 {
     return mailparse_stream_encode($srcFilePointer, $destFilePointer, $encoding);
 }
Пример #2
0
<?php

$f = fopen('/etc/passwd', 'r');
fclose($f);
var_dump(mailparse_uudecode_all($f));
var_dump(mailparse_determine_best_xfer_encoding($f));
var_dump(mailparse_stream_encode($f, $f, 'utf8'));
Пример #3
0
$text = "hello, this is some text=hello.";
$fp = tmpfile();
fwrite($fp, $text);
rewind($fp);
$dest = tmpfile();
mailparse_stream_encode($fp, $dest, "quoted-printable");
rewind($dest);
$data = fread($dest, 2048);
VS($data, "hello, this is some text=3Dhello.");
$text = "To: fred@bloggs.com\n" . "\n" . "blah blah blah From blah \$ \" & £ blah blah blah blah blah\n" . "From the first of the month, things will be different!\n" . "blah blah blah From blah\n" . "Frome is a town in Somerset.";
ob_start();
$fp = tmpfile();
fwrite($fp, $text);
rewind($fp);
$fpdest = tmpfile();
mailparse_stream_encode($fp, $fpdest, "quoted-printable");
rewind($fpdest);
fpassthru($fpdest);
fclose($fp);
fclose($fpdest);
$output = ob_get_contents();
ob_end_clean();
VS($output, "To: fred@bloggs.com\r\n" . "\r\n" . "blah blah blah From blah \$ \" & =C2=A3 blah blah blah blah blah\r\n" . "=46rom the first of the month, things will be different!\r\n" . "blah blah blah From blah\r\n" . "Frome is a town in Somerset.");
//////////////////////////////////////////////////////////////////////
$text = "To: fred@bloggs.com\n" . "\n" . "hello, this is some text hello.\n" . "blah blah blah.\n" . "\n" . "begin 644 test.txt\n" . "/=&AI<R!I<R!A('1E<W0*\n" . "`\n" . "end";
ob_start();
$fp = tmpfile();
fwrite($fp, $text);
$data = mailparse_uudecode_all($fp);
echo "BODY\n";
readfile($data[0]['filename']);