Created
January 20, 2013 11:26
-
-
Save deathowl/4577998 to your computer and use it in GitHub Desktop.
Getmxrr for windows server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Workaround, because Windows hosts suck ass big time | |
Requires: | |
nslookup - ie. Windows - with access to 4.2.2.* | |
PHP >= 4.0.3 | |
shell_exec() enabled - ie. safe mode disabled | |
*/ | |
function getmxrr($host, &$mx, &$weight=NULL){ | |
$res=explode("\n",strstr(shell_exec('nslookup -type=mx '.escapeshellarg($host).' 4.2.2.3'),$host)); | |
if(!isset($res[1])){ | |
$mx[]=FALSE; | |
return FALSE; | |
} | |
foreach($res as $v){ | |
$w=explode(' ',$v); | |
$mx[]=$w[7]; | |
if(isset($weight)){ | |
$weight[]=$w[3]{0}; | |
} | |
} | |
unset($mx[count($mx)-1]); | |
unset($weight[count($weight)-1]); | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment