function fromhost($server, &$havemx)
 {
     $this->_fromhost = $ret = $havemx = false;
     if (is_string($server)) {
         $server = FUNC::str_clear($server, array(' '));
         $server = strtolower(trim($server));
         if ($server != "") {
             $ret = true;
             $this->_fromhost = $server;
             if (FUNC::is_hostname($server)) {
                 $havemx = FUNC::is_win() ? FUNC::getmxrr_win($server, $mxhost) : getmxrr($server, $mxhost);
             }
         } else {
             throw new Exception('Invalid parameter value, on class SMTP::fromhost()', 512);
         }
     } else {
         throw new Exception('Invalid parameter type value, on class SMTP::fromhost()', 512);
     }
     return $ret;
 }
示例#2
0
 function getmxrr_win($hostname, &$mxhosts)
 {
     $mxhosts = array();
     if (is_string($hostname) && $hostname != "") {
         if (FUNC::is_hostname($hostname)) {
             $hostname = strtolower($hostname);
             $retstr = exec('nslookup -type=mx ' . $hostname, $retarr);
             if ($retstr && count($retarr) > 0) {
                 foreach ($retarr as $line) {
                     if (preg_match('/.*mail exchanger = (.*)/', $line, $matches)) {
                         $mxhosts[] = $matches[1];
                     }
                 }
             }
         } else {
             trigger_error('Invalid parameter format, on class FUNC::getmxrr_win()', 512);
         }
     } else {
         trigger_error('Invalid parameter type value, on class FUNC::getmxrr_win()', 512);
     }
     return count($mxhosts) > 0;
 }