Forum Moderators: coopster
<?php
$emails = array();
$pattern="/(?:[a-z0-9!#$%&'*+=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/";
$path = realpath('/home/*******/Mail/.family.directory/Browne, David & Nancy');
$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
foreach($objects as $name => $object){
if (is_file($name))//bypass "." and ".."
{echo "$name \n";
$handle = @fopen($name, "r");
if ($handle) {
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
//var_dump(mailparse_rfc822_parse_addresses($buffer));
preg_match_all($pattern, $buffer, $matches);
foreach($matches[0] as $email){
if (in_array($email, $emails)) {
}
else {
$emails[] = $email;
}
echo $email.", ";//emails display okay, some look truncated though
}
}
}
}
fclose($handle);
}
for($i = 0; $i < sizeof($emails); ++$i)
{
echo $emails[$i] . "\r\n";//emails don't display okay ?
}
?>