Be aware of "corporate mails" or users who do not understand character encoding too deeply (or do not care). You may (as we did) face mail where the whole mail body is encoded used i.e. Latin2 (and iso-8859-2 is given in multipart's charset header) but at the same time the body also contains text footer with UTF-8 characters in it... Yes, fu*g Microsoft Exchange V6.5 frontent will show that fine on the screen, but if when receive it:
mailparse_msg_extract_part_file() - filter conversion failed. Input message is probably incorrectly encoded in ....
so be extra careful and deal with all the possible errors to avoid mail loss.
mailparse_msg_extract_part_file
(PECL mailparse >= 0.9.0)
mailparse_msg_extract_part_file — メッセージセクションを展開/デコードする
説明
string mailparse_msg_extract_part_file
( resource
$mimemail
, mixed $filename
[, callable $callbackfunc
] )指定したファイル名のメッセージセクションを展開/デコードします。
セクションの内容は、transfer encoding に応じて適切にデコードされます。 base64、quoted-printable および uuencode 形式をサポートしています。
パラメータ
-
mimemail -
mailparse_msg_create() で作成した MIME リソース。
-
filename -
ファイル名あるいは有効なストリームリソース。
-
callbackfunc -
展開されたセクションに渡されるコールバック関数、あるいは
NULLを指定すると、この関数は展開したセクションを返します。省略した場合は標準出力に出力されます。
返り値
callbackfunc が NULL でない場合は、
成功時に TRUE を返します。
callbackfunc が NULL の場合は、
展開したセクションを文字列で返します。
エラー時には FALSE を返します。
参考
- mailparse_msg_extract_part() - メッセージセクションを展開/デコードする
- mailparse_msg_extract_whole_part_file() - ヘッダを含むメッセージセクションを、transfer encoding をデコードせずに展開する
carlos at wfmh dot org dot pl
24-Feb-2009 05:15
per at computer dot org
21-Oct-2004 10:09
mailparse_msg_extract_part_file() does not support file-wrappers as it needs to be able to use seek() on the file.
