Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 64262efd4e781bd2882af19b645d181b > files > 4

php-pear-Mail_Mbox-0.5.1-4mdv2010.0.noarch.rpm

<?php
//read the contents of the demo mailbox and
//use the Mail_Mime package to parse the mails

require_once 'Mail/Mbox.php';
require_once "Mail/mimeDecode.php";

//reads a mbox file
$file = dirname(__FILE__) . '/demobox';
echo 'Using file ' . $file . "\n";

$mbox = new Mail_Mbox($file);
$mbox->open();

for ($n = 0; $n < $mbox->size(); $n++) {
    $message = $mbox->get($n);

    $decode = new Mail_mimeDecode($message, "\r\n");
    $structure = $decode->decode();

    echo 'Mail #' . $n . "\n";
//    print_r($structure);
    echo 'Subject: ' . $structure->headers['subject'] . "\n";
    echo 'From:    ' . $structure->headers['from'] . "\n";
    echo "\n";
}

$mbox->close();
?>