note 101912 deleted from function.imap-bodystruct by danbrown
| From: | danbrown@php.net | Date: | Mon, 17 Jan 2011 22:53:26 +0000 |
| Subject: | note 101912 deleted from function.imap-bodystruct by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-175843@lists.php.net to get a copy of this message | ||
Note Submitter: user at scretchs dot com
----
function body($mbox, $mail, $mime = false, $section = false, &$body = false)
{
if(!$mime) $mime = imap_fetchstructure($mbox, $mail, FT_UID);
if(!$section) $section = !$mime->parts;
if(strtolower($mime->subtype) == 'mixed') $body = body($mbox, $mail,
$mime->parts[0], ($section ? $section.'.' : '').'1', $body);
elseif(strtolower($mime->subtype) == 'alternative')
{
foreach($mime->parts as $key => $value) $body = body($mbox, $mail, $value, ($section ?
$section.'.' : '').($key + 1), $body);
} else {
$data = imap_fetchbody($mbox, $mail, $section, FT_UID);
if($mime->encoding == 3) $data = base64_decode($data);
elseif($mime->encoding == 4) $data = imap_qprint($data);
if($data && $mime->type == 0)
{
if(strtolower($mime->subtype) == 'html') return mb_convert_encoding($data,
'UTF-8', $mime->parameters[0]->value);
elseif(strtolower($mime->subtype) == 'plain') return nl2br(htmlspecialchars($data));
}
}
return $body;
}
$body = body($mbox, $_GET['email']);