note 88033 added to function.getmxrr
| From: | php | Date: | Tue, 06 Jan 2009 22:18:25 +0000 |
| Subject: | note 88033 added to function.getmxrr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-148908@lists.php.net to get a copy of this message | ||
I decided to have a bash at this after doing a bit of research...
<?php
// getmxrr() support for Windows by HM2K <php [spat] hm2k.org>
function win_getmxrr($hostname, &$mxhosts, &$mxweight=false) {
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') return;
if (!is_array ($mxhosts) ) $mxhosts = array();
if (empty($hostname)) return;
$exec='nslookup -type=MX '.escapeshellarg($hostname);
@exec($exec, $output);
if (empty($output)) return;
$i=-1;
foreach ($output as $line) {
$i++;
if (preg_match("/^$hostname\tMX preference = ([0-9]+), mail exchanger = (.+)$/i", $line,
$parts)) {
$mxweight[$i] = trim($parts[1]);
$mxhosts[$i] = trim($parts[2]);
}
if (preg_match('/responsible mail addr = (.+)$/i', $line, $parts)) {
$mxweight[$i] = $i;
$mxhosts[$i] = trim($parts[1]);
}
}
return ($i!=-1);
}
// Define
if (!function_exists('getmxrr')) {
function getmxrr($hostname, &$mxhosts, &$mxweight=false) {
return win_getmxrr($hostname, $mxhosts, $mxweight);
}
}
/* example */
$domain='php.net';
echo "<pre>";
getmxrr($domain,$mxhosts,$mxweight);
print_r($mxhosts);
print_r($mxweight);
?>
----
Server IP: 87.124.35.190
Probable Submitter: 82.152.138.226
----
Manual Page -- http://www.php.net/manual/en/function.getmxrr.php
Edit -- https://master.php.net/note/edit/88033
Del: integrated -- https://master.php.net/note/delete/88033/integrated
Del: useless -- https://master.php.net/note/delete/88033/useless
Del: bad code -- https://master.php.net/note/delete/88033/bad+code
Del: spam -- https://master.php.net/note/delete/88033/spam
Del: non-english -- https://master.php.net/note/delete/88033/non-english
Del: in docs -- https://master.php.net/note/delete/88033/in+docs
Del: other reasons-- https://master.php.net/note/delete/88033
Reject -- https://master.php.net/note/reject/88033
Search -- https://master.php.net/manage/user-notes.php