Dutch PHP Conference 2026 - Call For Papers

Voting

: zero plus zero?
(Example: nine)

The Note You're Voting On

geoffbrisbine A T y a h o o DOT c o m
22 years ago
I was pretty disappointed that the Win32 build of PHP doesn't incorporate getmxrr so, since I'm a naive newbie, I decided to hack together my own (and I stress hack). This has been tested on Win 2000 and Win XP. There's no reason this shouldn't work on Win NT but it will not work on Win 9x (you need the nslookup command). It will finish with the array $mx that will be a multidimensional array with the MX preference, host name and ip address. You can do a print_r ( $mx ) to see what it looks like.

-----------------------------------------------

<?php
$command
= "nslookup -type=mx yahoo.com";
exec ( $command, $result );

$i = 0;
while ( list (
$key, $value ) = each ( $result ) ) {
if (
strstr ( $value, "mail exchanger" ) ) { $nslookup[$i] = $value; $i++; }
}

while ( list (
$key, $value ) = each ( $nslookup ) ) {
$temp = explode ( " ", $value );
$mx[$key][0] = $temp[3];
$mx[$key][1] = $temp[7];
$mx[$key][2] = gethostbyname ( $temp[7] );
}

array_multisort ( $mx );
?>

<< Back to user notes page

To Top