Пример #1
0
 function _sendtohost($hname, $arrto, $isrelay)
 {
     $ret = false;
     if ($hname == "localhost") {
         $ret = mail($this->_content['header']['to'], $this->_subject, implode('', $this->_content['body']), $this->_content['header']['local']);
         if (!$ret) {
             $ret = $this->_sendtoip('127.0.0.1', $arrto, $isrelay);
         }
     } else {
         if ($isrelay) {
             $ret = $this->_sendtoip($hname, $arrto, $isrelay);
         } else {
             if (FUNC::is_ipv4($hname)) {
                 $ret = $this->_sendtoip($hname, $arrto, $isrelay);
             } else {
                 $resmx = FUNC::is_win() ? FUNC::getmxrr_win($hname, $mxhost) : getmxrr($hname, $mxhost);
                 $iparr = array();
                 if ($resmx) {
                     foreach ($mxhost as $hostname) {
                         $iphost = gethostbyname($hostname);
                         if ($iphost != $hname && FUNC::is_ipv4($iphost) && !isset($iparr[$iphost])) {
                             $iparr[$iphost] = $iphost;
                         }
                     }
                 } else {
                     $iphost = gethostbyname($hname);
                     if ($iphost != $hname && FUNC::is_ipv4($iphost)) {
                         $iparr[$iphost] = $iphost;
                     }
                 }
                 if (count($iparr) > 0) {
                     foreach ($iparr as $ipaddr) {
                         if ($ret = $this->_sendtoip($ipaddr, $arrto, $isrelay)) {
                             break;
                         }
                     }
                 } else {
                     throw new Exception('Can not find any valid ip address for hostname "' . $hname . '", on class SMTP::_sendtohost()', 512);
                 }
             }
         }
     }
     return $ret;
 }
Пример #2
0
 function is_mail($addr, $vermx = false)
 {
     $ret = false;
     if (is_string($addr) && $addr != "") {
         $regs = '^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,6})$';
         if (eregi($regs, $addr)) {
             if (is_bool($vermx)) {
                 if ($vermx) {
                     $exp = explode('@', $addr);
                     $ret = FUNC::is_win() ? FUNC::getmxrr_win($exp[1], $mxh) : getmxrr($exp[1], $mxh);
                 } else {
                     $ret = true;
                 }
             } else {
                 trigger_error('Invalid secound parameter type value, on class FUNC::is_mail()', 512);
             }
         }
     } else {
         trigger_error('Invalid first parameter type value, on class FUNC::is_mail()', 512);
     }
     return $ret;
 }