/** * 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)); }
function email_count() { /** CLASSES **/ if (!class_exists('PEAR')) { require_once 'classes/PEAR-1.9.5/PEAR.php'; } if (!class_exists('Mail_Mbox')) { require_once 'classes/Mail/Mbox.php'; } //reads a mbox file $mbox = new Mail_Mbox($this->mail); $mbox->open(); $count = $mbox->size(); return $count; }
<?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();