if ($_SERVER[argc]<2) { printf("Usage : %s filename\n",$_SERVER['argv'][0]); exit; } $filename=strftime("%H%M.txt"); $out=fopen($filename,"a"); $counter=0; $fp=fopen($_SERVER['argv'][1],"r"); while ($data=fgets($fp,2000)) { $data=str_replace("\r","",$data); $data=str_replace("\n","",$data); if (checkmail($data)==TRUE) { printf("%s : %s \tGOOD_EMAIL!\n",$counter,$data); fputs($out,$data."\n"); } else printf("%s : %s \tBAD_EMAIL!\n",$counter,$data); $counter++; } fclose($fp); fclose($out); exit; // ------- function checkmail($mail){ $host = explode('@',$mail); list($account,$host) = $host; if (!getmxrr($host,$mxa)) $mxa = array($host); while (list ($key, $mx) = each($mxa)) { if ($mxg = @fsockopen ($mx,25,$ir,$sr,5)) { $out = fgets($mxg, 1024); if (substr($out,0,3) == "220") { fputs ($mxg, "HELO example.com\r\n"); $out = fgets ( $mxg, 1024 ); fputs ($mxg, "MAIL FROM: <{$mail}>\r\n"); $from = fgets ( $mxg, 1024 ); fputs ($mxg, "RCPT TO: <{$mail}>\r\n"); $to = fgets ($mxg, 1024); fputs ($mxg, "QUIT\r\n"); fclose($mxg); if (ereg ("^250", $from) && ereg ( "^250", $to )) return TRUE; return FALSE; } return FALSE; } return FALSE; } return FALSE; }
好用的 postfix mail log 統計軟體 pflogsumm
pflogsumm.pl is designed to provide an over-view of postfix activity, with just enough detail to give the administrator a “heads up” for potential trouble spots.
emerge net-mail/pflogsumm