php8.5
Home/ Manual/ mailparse / functions/ mailparse_stream_encode

mailparse_stream_encode

PHP function Edit on GitHub ✎

(PECL mailparse >= 0.9.0)

Streams data from source file pointer, apply encoding and write to destfp

Description

mailparse_stream_encode(resource $sourcefp, resource $destfp, string $encoding): bool

Streams data from the source file pointer, apply encoding and write to the destination file pointer.

Parameters

sourcefp

A valid file handle. The file is streamed through the parser.

destfp

The destination file handle in which the encoded data will be written.

encoding

One of the character encodings supported by the mbstring module.

Return Values

Success

Examples

mailparse_stream_encode() example

php
<?php

// email.eml contents: hello, this is some text=hello.
$fp = fopen('email.eml', 'r');

$dest = tmpfile();

mailparse_stream_encode($fp, $dest, "quoted-printable");

rewind($dest);

// Display new file contents
fpassthru($dest);

?>

The above example will output:

output
hello, this is some text=3Dhello.

Source: reference/mailparse/functions/mailparse-stream-encode.xml · from the official PHP manual (php/doc-en)