Before you can do anything with the mbox file, you need to create an instance of the Mail_Mbox class and open() it.
<?php require_once 'Mail/Mbox.php'; $mbox = new Mail_Mbox('/path/to/mbox'); $mbox->open(); //do more here ?> |
After opening the file, you can retrieve single messages via get(). The size() method helps you to determine the number of messages:
<?php //... initialisation for ($n = 0; $n < $mbox->size(); $n++) { $message = $mbox->get($n); //do something with the message text } ?> |
If you're done working with the file, close() it.
<?php //... other code $mbox->close(); ?> |
Also have a look at the Mail_Mbox examples directory in /path/to/pear/docs/Mail_Mbox/examples/.