輸出結果:

未命名  

 

<?php

function validate_email($email){
if(!preg_match("/^[\w\.-]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]+$/", $email))
return false;
list($prefix, $domain) = split("@", $email);
if(function_exists("getmxrr") && getmxrr($domain, $mxhosts)){
return $domain;
}elseif(@fsockopen($domain, 25, $errno, $errstr, 5)){
return $domain;
}else{
return false;
}
}


function re_getmxrr($hostname, &$mxhosts, &$mxweight=false) {
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') return;
if (!is_array ($mxhosts) ) $mxhosts = array();
if (empty($hostname)) return;
$exec='nslookup -type=MX '.escapeshellarg($hostname);
@exec($exec, $output);
if (empty($output)) return;
$i=-1;
foreach ($output as $line) {
if (preg_match("/^$hostname\tMX preference = ([0-9]+), mail exchanger = (.+)$/i", $line, $parts)) {
$i++;
$mxweight[$i] = trim($parts[1]);
$mxhosts[$i] = trim($parts[2]);
}
if (preg_match('/responsible mail addr = (.+)$/i', $line, $parts)) {
$i++;
$mxweight[$i] = $i;
$mxhosts[$i] = trim($parts[1]);
}
}
return ($i!=-1);
}

// Define
if (!function_exists('getmxrr')) {
function getmxrr($hostname, &$mxhosts, &$mxweight=false) {
return re_getmxrr($hostname, $mxhosts, $mxweight);
}
}

function analysis_mail_exchanger($email){
$debug = false;
//$debug = true;
$known_provider = array(
"google_apps" => array(
"aspmx.l.google.com" => 10,
"alt1.aspmx.l.google.com" => 20,
"alt2.aspmx.l.google.com" => 30,
"aspmx2.googlemail.com" => 40,
"aspmx3.googlemail.com" => 50,
),
"google_gmail" => array(
"gmail-smtp-in-v4v6.l.google.com" => 5,
"alt1.gmail-smtp-in.l.google.com" => 10,
"alt2.gmail-smtp-in.l.google.com" => 20,
"alt3.gmail-smtp-in.l.google.com" => 30,
"alt4.gmail-smtp-in.l.google.com" => 40,
),
"microsoft_hotmail" => array(
"mx3.hotmail.com" => 5,
"mx2.hotmail.com" => 5,
"mx1.hotmail.com" => 5,
"mx4.hotmail.com" => 5,
),
"microsoft_domains" => '.hotmail.com',
"yahoo_usa" => array(
"mta7.am0.yahoodns.net" => 1,
"mta6.am0.yahoodns.net" => 1,
"mta5.am0.yahoodns.net" => 1,
),
"yahoo_china" => '.yahoo.com',
"yahoo_biz" => array(
"mx1.biz.mail.yahoo.com" => 20,
"mx5.biz.mail.yahoo.com" => 30,
),
"tencent_<a href="http://www.it165.net/qq/" target="_blank" class="keylink">qq</a>" => array(
"mx3.<a href="http://www.it165.net/qq/" target="_blank" class="keylink">qq</a>.com" => 10,
"mx2.qq.com" => 20,
"mx1.qq.com" => 30,
),
"tencent_domains" => array(
"mxdomain.qq.com" => 10,
),
"tencent_exmail" => array(
"mxbiz1.qq.com" => 5,
"mxbiz2.qq.com" => 10,
),
"netease_163" => array(
"163mx01.mxmail.netease.com" => 10,
"163mx03.mxmail.netease.com" => 10,
"163mx02.mxmail.netease.com" => 10,
"163mx00.mxmail.netease.com" => 50,
),
"netease_vip163" => array(
"vip163mx01.mxmail.netease.com" => 10,
"vip163mx00.mxmail.netease.com" => 50,
),
"netease_126" => array(
"126mx02.mxmail.netease.com" => 10,
"126mx01.mxmail.netease.com" => 10,
"126mx00.mxmail.netease.com" => 50,
),
"netease_vip126" => array(
"mx.vip.126.com" => 50,
),
"netease_yeah" => array(
"yeahmx01.mxmail.netease.com" => 10,
"yeahmx00.mxmail.netease.com" => 50,
),
"netease_free" => array(
"mx.mail.ym.163.com" => 10,
),
"netease_qiye" => array(
"qiye163mx02.mxmail.netease.com" => 10,
"qiye163mx01.mxmail.netease.com" => 50,
),
"sina_mail" => array(
"freemx.sinamail.sina.com.cn" => 5,
"freemx3.sinamail.sina.com.cn" => 10,
"freemx2.sinamail.sina.com.cn" => 10,
"freemx1.sinamail.sina.com.cn" => 10,
),
"sina_vip" => array(
"mx3.vip.sina.com" => 5,
"mx2.vip.sina.com" => 10,
"mx1.vip.sina.com" => 10,
"sinamx.vip.sina.com" => 20,
),
"sina_free" => array(
"mx.exmail.sina.com" => 10,
),
"sina_qiye" => '.sina.net',
"sohu_mail" => array(
"sohumx1.sohu.com" => 5,
"sohumx.h.a.sohu.com" => 10,
),
"sohu_vip" => array(
"mx.vip.sohu.com" => 10,
),
"sohu_free" => array(
"mx.mail.sohu.net" => 10,
),
);
if($domain = validate_email($email)){
$result = 'other';
getmxrr($domain, $mxhosts, $mxweight);
for($i=0; $i<count($mxhosts); $i++){
$mxs[strtolower($mxhosts[$i])] = $mxweight[$i];
}
asort($mxs);
//$mxs = array_keys($mxs);
if($debug){
foreach ($mxs as $key => $value) {
echo '"' . $key . '" => ' . $value . ",\r\n";
}
exit();
}else{
foreach ($known_provider as $key => $value) {
if(is_array($value)){
ksort($mxs);
ksort($value);
if($value==$mxs){
$result = $key;
break;
}
}else{ //like as ms live domains
foreach ($mxs as $k => $v) {
if(stristr($k, $value) !== FALSE){
$result = $key;
break;
}
break; //only once
}
}
}
}
}else{
$result = 'unvalid';
}
return $result;
}

echo analysis_mail_exchanger('admin@gump.me');
?>

 

下載檔案:43270441

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()