note 64352 deleted from function.getmxrr by nlopess

From: Date: Sun, 24 Sep 2006 15:16:03 +0000
Subject: note 64352 deleted from function.getmxrr by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117535@lists.php.net to get a copy of this message
Note Submitter: choward AT fast DOT net DOT NO SPAM PLZ ---- Below Code Used and edited from -ng4rrjanbiah at rediffmail dot com- posted note. Testing on Windows 2000 Advanced Server. PHP v4.4.1 function getmxrr($hostname, &$mxhosts) { $mxhosts = array(); exec('%SYSTEMDIRECTORY%\\nslookup.exe -q=mx '.$hostname, $result_arr); foreach($result_arr as $line) { if (preg_match("/.*mail exchanger = (.*)/", $line, $matches)) $mxhosts[] = $matches[1]; } return( count($mxhosts) > 0 ); }//--End of workaround //test.. getmxrr('yahoo.com', $mxhosts); print_r($mxhosts); As you can see the only thing i had to do in order to make this work was add a direct path to nslookup and add the .exe extension. You can use either the "Type" or "Q" parameter, both worked for me. I am not sure as to why the inital script failed... Safe Mode is on, but that is not the culprit. If i look into it and find an answer i will post it. My initial thoughts are that the SystmDir and WinDir Environment Vars are set to C:\WINNT when i would think SystemDir is actually supposed to be C:\WINNT\System32 for windows systems... but i also think that because C:\WINNT\System32 is in my Windows OS Environmental Var PATH that it shouldn't matter so i am not sure why i had to put in the whole path, but either way it now works. If anyone has some insight or simply wants to point me to something i can read, that'd be much appreciated as i will probably not think about this issue again... Especially since this particular system has had way too many changes to it and programs installed etc... it is an all around test unit. The issue may be mine alone, but i thought i would post this in hopes of saving someone time just in case.

« previous php.notes (#117535) next »