Mailing list sorter.

Ben Hartley

Active Member
Reputation
0
Simple command line application for sorting mail lists into there respective domains.

PHP:
#!/usr/bin/php
<?php
/************************
*   -----Usage:----     *
* $ chmod 777 sort.php  *
* $ sudo php sort.php   *
*************************/
// Mail sorter by slack3r.

fwrite(STDOUT, "Rnter the name of the file to sort: ");
$input = str_ireplace("\n", "", fgets(STDIN));
fwrite(STDOUT, "Enter mail extension to sort e.g. @yahoo.com: ");
$mail = str_ireplace("\n", "", fgets(STDIN));
fwrite(STDOUT, "Enter the file name of the sorted list e.g. yahoolist.txt: ");
$output = str_ireplace("\n", "", fgets(STDIN));

$content = file_get_contents($input);
$content = explode("\r\n",$content);

foreach ($content AS $aline) 
             {
             if(preg_match_all("/(.*?).$mail/i", $aline, $match)) 
            {
$line = implode("\n", $match[0]);


$a = fopen($output, 'a+') or die("can't open file");
fwrite($a, $line);
fclose($a);
print "Done..";

}else{

print "not matched";

        }
}
?>
 
Back
Top