From: Alan Knowles Date: Wed, 6 Apr 2011 15:18:36 +0000 (+0800) Subject: NotifySend.php X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=326b336aadb113c48d75bb35e79c68f83c74647f;p=Pman.Core NotifySend.php --- diff --git a/NotifySend.php b/NotifySend.php index 7dc47773..1919143c 100644 --- a/NotifySend.php +++ b/NotifySend.php @@ -63,6 +63,9 @@ class Pman_Core_NotifySend extends Pman // should we fetch the watch that caused it.. - which should contain the method to call.. $dom = array_pop(explode('@', $p->email)); + bool getmxrr ( $dom , array &$mxhosts [, array &$weight ] ) + + Mail::factory('smtp', array( 'host' => 'smtp.gmail.com', 'persist' => FALSE @@ -73,7 +76,23 @@ class Pman_Core_NotifySend extends Pman die("DONE\n"); } - - + function mx($fqdn) + { + $mx_records = array(); + $mx_weight = array(); + + 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; + } } \ No newline at end of file