{
$mx_records = array();
$mx_weight = array();
+ $mxs = array();
+ if (!getmxrr($fqdn, $mx_records, $mx_weight)) {
+ return araray($fqdn);
+ }
+
+ asort($mx_weight)
- if (getmxrr($fqdn, $mx_records, $mx_weight)) {
- // copy mx records and weight into array $mxs
- // ignore multiple mx's at the same weight << that's just dumb...
- for ($i = 0; $i < count($mx_records); $i++) {
- $mxs[$mx_weight[$i]] = $mx_records[$i];
- }
- // sort array mxs to get servers with highest priority
- ksort ($mxs, SORT_NUMERIC);
- reset ($mxs);
- } else {
- // No MX so use A
- $mxs[0]= $fqdn;
+ forach($mx_weight as $k => $weight) {
+ $mxs[] = $mx_records[$k];
}
+ return $mxs;
}
- return $mxs;
+
}
\ No newline at end of file