note 70401 added to function.getmxrr

From: Date: Sun, 15 Oct 2006 00:28:05 +0000
Subject: note 70401 added to function.getmxrr
Groups: php.notes 
Request: Send a blank email to php-notes+get-118535@lists.php.net to get a copy of this message
This function has some strange side effects when dealing with aliases... My function: if (getmxrr($fqdn, $mx_records, $mx_weight)) { // copy mx records and weight into array $mxs // ignore multiple mx's at the same weight 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; } fails because a $fqdn containing an alias returns a true yet on return both $mx_records and $mx_weight contain nothing! The solution until this gets fixed is to replace if (getmxrr($fqdn, $mx_records, $mx_weight)) with // Handle aliases etc. if ($result = getmxrr($fqdn, $mx_records, $mx_weight)) { if(!isset($mx_records) || (count($mx_records) == 0)) $result = false; } // Process MXs if ($result) { Hope this helps others.... Tom ---- Server IP: 66.207.199.35 Probable Submitter: 69.26.64.52 (proxied: 69.26.94.100) ---- Manual Page -- http://www.php.net/manual/en/function.getmxrr.php Edit -- https://master.php.net/note/edit/70401 Del: integrated -- https://master.php.net/note/delete/70401/integrated Del: useless -- https://master.php.net/note/delete/70401/useless Del: bad code -- https://master.php.net/note/delete/70401/bad+code Del: spam -- https://master.php.net/note/delete/70401/spam Del: non-english -- https://master.php.net/note/delete/70401/non-english Del: in docs -- https://master.php.net/note/delete/70401/in+docs Del: other reasons-- https://master.php.net/note/delete/70401 Reject -- https://master.php.net/note/reject/70401 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#118535) next »