Skip to content

Instantly share code, notes, and snippets.

@deathowl
Created January 20, 2013 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deathowl/4577998 to your computer and use it in GitHub Desktop.
Save deathowl/4577998 to your computer and use it in GitHub Desktop.
Getmxrr for windows server
/*
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