summaryrefslogtreecommitdiff
path: root/import/read.php
blob: 37dd1977f2b461fe7edae7c0cb80a9ed39825dd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
//read the subjects of the demo mailbox

require_once 'Mbox.php';
require_once 'mimeDecode.php';

//reads a mbox file
$file = '/srv/website/bitweaver/contact/data/Stockport';
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\n\n\n";
	$Decoder = new Mail_mimeDecode( $message );
	$params = [
	'include_bodies' => TRUE,
	'decode_bodies'  => TRUE,
	'decode_headers' => TRUE,
	];
	$Decoded = $Decoder->decode($params);
	print_r($Decoded);
}

$mbox->close();
?>