/**
     * While the bug was incorrect, it showed that we do not
     * escape messages properly.
     * Here we test that escaped messages are stored and read
     * properly.
     *
     * @link http://pear.php.net/bugs/bug.php?id=16758
     *
     * @return void
     */
    public function testBug16758()
    {
        $msg = <<<MBX
From someone.who@loves.you
Subject: test

From now on, no more bugs!
>From what I said...
>>From where are you coming?

MBX;
        //file does not exist yet
        $mbox = new Mail_Mbox(self::$filecopy);
        $this->assertTrue($mbox->open());
        $this->assertTrue($mbox->append($msg));
        $mbox->close();
        $mbox = new Mail_Mbox(self::$filecopy);
        $this->assertTrue($mbox->open());
        $this->assertEquals(1, $mbox->size());
        $this->assertEquals($msg, $mbox->get(0));
    }
Exemple #2
0
<?php

//read the subjects of the demo mailbox
require_once 'Mail/Mbox.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);
    preg_match('/Subject: (.*)$/m', $message, $matches);
    $subject = $matches[1];
    echo 'Mail #' . $n . ': ' . $subject . "\n";
}
$mbox->close();