Content-Typeが"multipart/mixed"なメールをもっと簡単に処理する

| | Comments (0) | TrackBacks (0)

前回のエントリでmultipartのバウンダリ文字列を抜き取る処理を記述したけれど、
multipartを分解したいだけなら、Mail/mimeDecode.php の基本処理で事足りたようである...

<?php 
require_once('Mail/mimeDecode.php');

$_params['include_bodies'] = true;
$_params['decode_bodies'] = true;
$_params['decode_headers'] = true;
$_params['input'] = file_get_contents('php://stdin');
$_structure = Mail_mimeDecode::decode($_params);

foreach ($_structure->parts as $_part) {
    //$_part->body;
}

?>

この例では、foreachの中の

$_part->body;
で分解された個々のbodyを取得できる。
本来、multipartかどうかの処理や、その他の細かい処理が必要になるが、そこら辺はPHPプロ!の記事を参照されたい。

0 TrackBacks

Listed below are links to blogs that reference this entry: Content-Typeが"multipart/mixed"なメールをもっと簡単に処理する.

TrackBack URL for this entry: http://mahata.net/movabletype/mt-tb.cgi/2985

Leave a comment

About this Entry

This page contains a single entry by mahata published on October 25, 2007 12:24 PM.

Content-Typeが"multipart/mixed"なメールのboundary文字列を取得する was the previous entry in this blog.

やばい is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.