CakeFest 2024: The Official CakePHP Conference

mailparse_uudecode_all

(PECL mailparse >= 0.9.0)

mailparse_uudecode_all ファイルポインタからデータをスキャンし、uuencode されたファイルを展開する

説明

mailparse_uudecode_all(resource $fp): array

指定したファイルポインタからのデータを読み込み、 uuencode されたファイルを一時ファイルに展開します。

パラメータ

fp

有効なファイルポインタ。

戻り値

ファイル名の情報を含む連想配列の配列を返します。

filename 作成された一時ファイルへのパス。
origfilename もとのファイル名。uuencode されたパートにのみ存在します。
最初の filename エントリがメッセージ本文、次のエントリがデコードされた uuencode ファイルとなります。

例1 mailparse_uudecode_all() の例

<?php

$text
= <<<EOD
To: fred@example.com

hello, this is some text hello.
blah blah blah.

begin 644 test.txt
/=&AI<R!I<R!A('1E<W0*
`
end

EOD;

$fp = tmpfile();
fwrite($fp, $text);

$data = mailparse_uudecode_all($fp);

echo
"BODY\n";
readfile($data[0]["filename"]);
echo
"UUE ({$data[1]['origfilename']})\n";
readfile($data[1]["filename"]);

// 後始末をします
unlink($data[0]["filename"]);
unlink($data[1]["filename"]);

?>

上の例の出力は以下となります。

BODY
To: fred@example.com

hello, this is some text hello.
blah blah blah.

UUE (test.txt)
this is a test

add a note

User Contributed Notes 1 note

up
0
mat at phpconsulting dot com
20 years ago
As an alternative, uudecode() can be called as static function as follows:

$file =& Mail_mimeDecode::uudecode($some_text);

This will return the following arrays:
@param string Input body to look for attachments in
@return array Decoded bodies, filenames and permissions
To Top