Tutorial – How to use Mail_Mbox

How to use Mail_Mbox

Before you can do anything with the mbox file, you need to create an instance of the Mail_Mbox class and open() it.

require_once 'Mail/Mbox.php';
$mbox = new Mail_Mbox('/path/to/mbox');
//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:

//... 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.

//... other code

Also have a look at the Mail_Mbox examples directory in /path/to/pear/docs/Mail_Mbox/examples/.

Class to read mbox mail files. (Previous) Create a new Mbox class instance. (Next)
Last updated: Sat, 16 Feb 2019 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report.
View this page in:
  • English

User Notes:

There are no user contributed notes for this page.