当前位置: 首页>>代码示例>>PHP>>正文


PHP getmxrr函数代码示例

本文整理汇总了PHP中getmxrr函数的典型用法代码示例。如果您正苦于以下问题:PHP getmxrr函数的具体用法?PHP getmxrr怎么用?PHP getmxrr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getmxrr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validEmail

 function validEmail($email, $extended = false)
 {
     if (empty($email) or !is_string($email)) {
         return false;
     }
     if (!preg_match('/^([a-z0-9_\'&\\.\\-\\+])+\\@(([a-z0-9\\-])+\\.)+([a-z0-9]{2,10})+$/i', $email)) {
         return false;
     }
     if (!$extended) {
         return true;
     }
     $config = acymailing_config();
     if ($config->get('email_checkpopmailclient', false)) {
         if (preg_match('#^.{1,5}@(gmail|yahoo|aol|hotmail|msn|ymail)#i', $email)) {
             return false;
         }
     }
     if ($config->get('email_checkdomain', false) and function_exists('getmxrr')) {
         $domain = substr($email, strrpos($email, '@') + 1);
         $mxhosts = array();
         $checkDomain = getmxrr($domain, $mxhosts);
         if (!empty($mxhosts) && strpos($mxhosts[0], 'hostnamedoesnotexist')) {
             array_shift($mxhosts);
         }
         if (!$checkDomain || empty($mxhosts)) {
             $dns = @dns_get_record($domain, DNS_A);
             if (empty($dns)) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:andreassetiawanhartanto,项目名称:PDKKI,代码行数:33,代码来源:acyuser.php

示例2: getWebAppUrl

 /**
  * Get mail web application url
  *
  * @example `bob@idarex.com` Web url is `http://exmail.qq.com`
  * @param $email
  * @return string
  */
 public static function getWebAppUrl($email)
 {
     list(, $emailDomain) = explode('@', $email);
     switch ($emailDomain) {
         case "163.com":
             return "http://mail.163.com";
             break;
         case "qq.com":
             return "http://mail.qq.com";
             break;
         case "126.com":
             return "http://mail.126.com";
             break;
         case "gmail.com":
             return "http://mail.google.com";
             break;
         default:
             $mxHosts = [];
             if (getmxrr($emailDomain, $mxHosts)) {
                 foreach ($mxHosts as $row) {
                     if (isset(static::$mxServerWebAppUrl[$row])) {
                         return static::$mxServerWebAppUrl[$row];
                     }
                 }
             }
             return "http://mail.{$emailDomain}";
             break;
     }
 }
开发者ID:yiier,项目名称:helpers,代码行数:36,代码来源:MailHelper.php

示例3: ValidateEmailHost

 function ValidateEmailHost($email, $hosts = 0)
 {
     if (!$this->ValidateEmailAddress($email)) {
         return 0;
     }
     //if(strpos(PHP_OS,'WIN') !== false) return(-1);
     $user = strtok($email, "@");
     $domain = strtok("");
     if (getmxrr($domain, &$hosts, &$weights)) {
         $mxhosts = array();
         for ($host = 0; $host < count($hosts); $host++) {
             $mxhosts[$weights[$host]] = $hosts[$host];
         }
         ksort($mxhosts);
         for (reset($mxhosts), $host = 0; $host < count($mxhosts); Next($mxhosts), $host++) {
             $hosts[$host] = $mxhosts[Key($mxhosts)];
         }
     } else {
         $hosts = array();
         if (strcmp(@gethostbyname($domain), $domain) != 0) {
             $hosts[] = $domain;
         }
     }
     return count($hosts) != 0;
 }
开发者ID:TiMoChao,项目名称:xingfu,代码行数:25,代码来源:emailverify.class.php

示例4: validate

 /**
  * @param Field $field
  * @return bool
  */
 public function validate(Field $field)
 {
     if ($field->isValueEmpty() === true) {
         return true;
     }
     $fieldValue = $field->getValue();
     $emailValid = filter_var($fieldValue, FILTER_VALIDATE_EMAIL);
     if ($emailValid === false) {
         return false;
     }
     if ($this->checkMx === false) {
         return true;
     }
     $domain = substr($fieldValue, strrpos($fieldValue, '@') + 1);
     $mxRecords = array();
     if (getmxrr(idn_to_ascii($domain), $mxRecords) === true) {
         return true;
     }
     // Port 25 fallback check if there's no MX record
     $aRecords = dns_get_record($domain, DNS_A);
     if (count($aRecords) <= 0) {
         return false;
     }
     $connection = @fsockopen($aRecords[0]['ip'], 25);
     if (is_resource($connection) === true) {
         fclose($connection);
         return true;
     }
     return false;
 }
开发者ID:TiMESPLiNTER,项目名称:formHandler,代码行数:34,代码来源:ValidEmailAddressRule.php

示例5: isValidEmail

 /**
  * implementation of isValidEmail by linuxjournal.
  * @link http://www.linuxjournal.com/article/9585?page=0,3
  * @return boolean
  */
 private function isValidEmail($email, $remoteCheck)
 {
     // check for all the non-printable codes in the standard ASCII set,
     // including null bytes and newlines, and exit immediately if any are found.
     if (preg_match("/[\\000-\\037]/", $email)) {
         return false;
     }
     $pattern = "/^[-_a-z0-9\\'+*\$^&%=~!?{}]++(?:\\.[-_a-z0-9\\'+*\$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\\.[a-z]{2,6}|\\d{1,3}(?:\\.\\d{1,3}){3})(?::\\d++)?\$/iD";
     if (!preg_match($pattern, $email)) {
         return false;
     }
     if ($remoteCheck === true) {
         // Validate the domain exists with a DNS check
         // if the checks cannot be made (soft fail over to true)
         list($user, $domain) = explode('@', $email);
         if (function_exists('checkdnsrr')) {
             if (!checkdnsrr($domain, "MX")) {
                 // Linux: PHP 4.3.0 and higher & Windows: PHP 5.3.0 and higher
                 return false;
             }
         } else {
             if (function_exists("getmxrr")) {
                 if (!getmxrr($domain, $mxhosts)) {
                     return false;
                 }
             }
         }
     }
     return true;
 }
开发者ID:nourdine,项目名称:phpv,代码行数:35,代码来源:EmailValidator.php

示例6: valid_email

function valid_email($email = '')
{
    global $validate_mail_host;
    // checks proper syntax
    if (preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/', $email)) {
        if ($validate_mail_host) {
            // gets domain name
            list($username, $domain) = split('@', $email);
            // checks for if MX records in the DNS
            $mxhosts = array();
            if (getmxrr($domain, $mxhosts)) {
                // mx records found
                foreach ($mxhosts as $host) {
                    if (fsockopen($host, 25, $errno, $errstr, 7)) {
                        return true;
                    }
                }
                return false;
            } else {
                // no mx records, ok to check domain
                if (fsockopen($domain, 25, $errno, $errstr, 7)) {
                    return true;
                } else {
                    return false;
                }
            }
        } else {
            return true;
        }
    } else {
        return false;
    }
}
开发者ID:BACKUPLIB,项目名称:minimanager,代码行数:33,代码来源:valid_lib.php

示例7: checkAddress

 function checkAddress($sAddress)
 {
     if (!is_valid_email_address($sAddress)) {
         return CA_ERROR_ADDRESS_INVALID;
     }
     /* get MX records
      */
     $sDomain = substr($sAddress, strpos($sAddress, '@') + 1);
     if (getmxrr($sDomain, $mx_records, $mx_weight) == false) {
         $mx_records = array($sDomain);
         $mx_weight = array(0);
     }
     // sort MX records
     $mxs = array();
     for ($i = 0; $i < count($mx_records); $i++) {
         $mxs[$i] = array('mx' => $mx_records[$i], 'prio' => $mx_weight[$i]);
     }
     usort($mxs, "mailcheck_cmp");
     reset($mxs);
     // check address with each MX until one mailserver can be connected
     for ($i = 0; $i < count($mxs); $i++) {
         $retval = $this->pCheckAddress($sAddress, $mxs[$i]['mx']);
         if ($retval != CA_ERROR_CONNECT) {
             return $retval;
         }
     }
     return CA_ERROR_CONNECT;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:28,代码来源:mailcheck.class.php

示例8: mxconnect

 public static function mxconnect($host = null, $port = null, $tout = null, $name = null, $context = null, $debug = null)
 {
     global $_RESULT;
     $_RESULT = array();
     if (!FUNC5::is_debug($debug)) {
         $debug = debug_backtrace();
     }
     if (!is_string($host)) {
         FUNC5::trace($debug, 'invalid host type');
     } else {
         $host = strtolower(trim($host));
         if (!($host != '' && FUNC5::is_hostname($host, true, $debug))) {
             FUNC5::trace($debug, 'invalid host value');
         }
     }
     $res = FUNC5::is_win() ? FUNC5::getmxrr_win($host, $arr, $debug) : getmxrr($host, $arr);
     $con = false;
     if ($res) {
         foreach ($arr as $mx) {
             if ($con = self::connect($mx, $port, null, null, null, $tout, $name, $context, $debug)) {
                 break;
             }
         }
     }
     if (!$con) {
         $con = self::connect($host, $port, null, null, null, $tout, $name, $context, $debug);
     }
     return $con;
 }
开发者ID:voitto,项目名称:dbscript,代码行数:29,代码来源:SMTP5.php

示例9: process

 protected function process()
 {
     $email = $_POST['mail_sender'];
     $res = null;
     $user = null;
     $domain = null;
     $MXHost = null;
     preg_match("/\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*/", $email, $res);
     $translator = $this->application->get('translator');
     if (!$res || $res[0] !== $email || empty($email)) {
         $this->contactStatus = $translator->translate('mail_invalide');
     } else {
         list($user, $domain) = explode('@', $email);
         if (!getmxrr($domain, $MXHost)) {
             $this->contactStatus = $translator->translate('mail_invalide');
         } else {
             $mail = new Mailer();
             $mail->addRecipient('developpeurs@8thwonderland.com', '');
             $mail->addFrom($email, '');
             $mail->addSubject($_POST['mail_title'], '');
             $mail->html = "<table><tr><td>" . utf8_decode('Identité') . " :<br/>====================</td></tr>" . "<tr><td>{$_POST['mail_sender']}<br/></td></tr>" . "<tr><td>Message :<br/>====================</td></tr>" . "<tr><td>" . nl2br(htmlspecialchars(utf8_decode($_POST['mail_message']))) . "</td></tr></table>";
             if (!$mail->send()) {
                 $this->contactStatus = $mail->errorLog();
             }
         }
     }
 }
开发者ID:ChazalFlorian,项目名称:8thWonderland,代码行数:27,代码来源:MailController.php

示例10: get_mx

 function get_mx($hostname)
 {
     if (strpos($hostname, '@')) {
         list($user, $hostname) = explode('@', $hostname);
     }
     // split hostname from email address
     if (function_exists('getmxrr')) {
         @getmxrr($hostname, $mxhosts, $mxweight);
     }
     // check for a true MX record
     if (isset($mxhosts) && !empty($mxhosts)) {
         return array_shift($mxhosts);
     } else {
         // RFC says use the A line if there is no MX
         $ip = gethostbyname($hostname);
         // get the ip from hostname
         if ($ip != $hostname) {
             // continue if returned ip not hostname
             $hostname = gethostbyaddr($ip);
             // get the rdns (real) hostname
             $ip = gethostbyname($hostname);
             // check the (real) hostname has an A record
             if ($ip != $hostname) {
                 return $hostname;
             }
             // return if returned ip not hostname
         }
     }
     // If all else fails...
     return $hostname;
 }
开发者ID:digitaldevelopers,项目名称:alegrocart,代码行数:31,代码来源:mail.php

示例11: checkEmail

function checkEmail($Email)
{
    if (substr_count(PHP_OS, 'win') || substr_count(PHP_OS, 'Win') || substr_count(PHP_OS, 'WIN')) {
        function getmxrr($hostname, &$mxhosts)
        {
            $mxhosts = array();
            exec('nslookup -type=mx ' . $hostname, $result_arr);
            foreach ($result_arr as $line) {
                if (preg_match("/.*mail exchanger = (.*)/", $line, $matches)) {
                    $mxhosts[] = $matches[1];
                }
            }
            return count($mxhosts) > 0;
        }
    }
    if (!eregi("^[a-zA-Z0-9\\_\\-\\.]+@[a-zA-Z0-9\\-]+\\.[a-zA-Z0-9\\-\\.]+\$", $Email)) {
        return false;
    } else {
        list($Username, $Domain) = split("@", $Email);
        if (getmxrr($Domain, $MXHost)) {
            return true;
        } else {
            if (fsockopen($Domain, 25, $errno, $errstr, 30)) {
                return true;
            } else {
                return false;
            }
        }
        return true;
    }
}
开发者ID:bogorya,项目名称:kancbfl,代码行数:31,代码来源:check_email.php

示例12: valid_email

function valid_email($email = "")
{
    global $validate_mail_host;
    // checks proper syntax
    if (preg_match("/^([\\w\\!\\#\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\`{\\|\\}\\~]+\\.)*[\\w\\!\\#\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\`{\\|\\}\\~]+@((((([a-z0-9]{1}[a-z0-9\\-]{0,62}[a-z0-9]{1})|[a-z])\\.)+[a-z]{2,6})|(\\d{1,3}\\.){3}\\d{1,3}(\\:\\d{1,5})?)\$/i", $email)) {
        if ($validate_mail_host) {
            // gets domain name
            list($username, $domain) = split("@", $email);
            // checks for if MX records in the DNS
            $mxhosts = array();
            if (getmxrr($domain, $mxhosts)) {
                // mx records found
                foreach ($mxhosts as $host) {
                    if (fsockopen($host, 25, $errno, $errstr, 7)) {
                        return true;
                    }
                }
                return false;
            } else {
                // no mx records, ok to check domain
                if (fsockopen($domain, 25, $errno, $errstr, 7)) {
                    return true;
                } else {
                    return false;
                }
            }
        } else {
            return true;
        }
    } else {
        return false;
    }
}
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:33,代码来源:valid_lib.php

示例13: validEmail

 function validEmail($email, $extended = false)
 {
     if (empty($email) or !is_string($email)) {
         return false;
     }
     if (!preg_match('/^([a-z0-9_\'&\\.\\-\\+=])+\\@(([a-z0-9\\-])+\\.)+([a-z0-9]{2,10})+$/i', $email)) {
         return false;
     }
     if (!$extended) {
         return true;
     }
     $config = acymailing_config();
     if ($config->get('email_checkpopmailclient', false)) {
         if (preg_match('#^.{1,5}@(gmail|yahoo|aol|hotmail|msn|ymail)#i', $email)) {
             return false;
         }
     }
     if ($config->get('email_checkdomain', false) and function_exists('getmxrr')) {
         $domain = substr($email, strrpos($email, '@') + 1);
         $mxhosts = array();
         $checkDomain = getmxrr($domain, $mxhosts);
         if (!empty($mxhosts) && strpos($mxhosts[0], 'hostnamedoesnotexist')) {
             array_shift($mxhosts);
         }
         if (!$checkDomain || empty($mxhosts)) {
             $dns = @dns_get_record($domain, DNS_A);
             if (empty($dns)) {
                 return false;
             }
         }
     }
     $object = new stdClass();
     $object->IP = $this->getIP();
     $object->emailAddress = $email;
     if ($config->get('email_botscout', false)) {
         $botscoutClass = new acybotscout();
         $botscoutClass->apiKey = $config->get('email_botscout_key');
         if (!$botscoutClass->getInfo($object)) {
             return false;
         }
     }
     if ($config->get('email_stopforumspam', false)) {
         $email_stopforumspam = new acystopforumspam();
         if (!$email_stopforumspam->getInfo($object)) {
             return false;
         }
     }
     if ($config->get('email_iptimecheck', 0)) {
         $lapseTime = time() - 7200;
         $db = JFactory::getDBO();
         $db->setQuery('SELECT COUNT(*) FROM #__acymailing_subscriber WHERE created > ' . intval($lapseTime) . ' AND ip = ' . $db->Quote($object->IP));
         $nbUsers = $db->loadResult();
         if ($nbUsers >= 3) {
             return false;
         }
     }
     return true;
 }
开发者ID:freaqzilla,项目名称:joomla-site,代码行数:58,代码来源:acyuser.php

示例14: parseEmail

/** Parst eine E-Mail Adresse und prüft, ob Host existiert
 *
 * @param string $email Die zu parsende E-Mail Adresse
 * @return mixed Die E-Mail Adresse, falls erfolgreich, false andernfalls
 * @author Cédric Neukom
 */
function parseEmail($email)
{
    $host = preg_replace('/^.+@(.+)$/', '$1', $email);
    if (getmxrr($host, $hosts)) {
        return $email;
    } else {
        return false;
    }
}
开发者ID:nksarea,项目名称:nksarea,代码行数:15,代码来源:parseEmail.fn.php

示例15: validate

 /**
  * Sends the request to a server for validating
  * the existance of an email adress
  * @return boolean true if response was received before timeout
  */
 public function validate($email)
 {
     if (!preg_match('/([^\\@]+)\\@(.+)$/', $email, $matches)) {
         return false;
     }
     $user = $matches[1];
     $domain = $matches[2];
     if (!function_exists('checkdnsrr')) {
         throw new Exception(sprintf('%s could not find function "checkdnsrr"', __CLASS__));
     }
     if (!function_exists('getmxrr')) {
         throw new Exception(sprintf('%s could not find function "getmxrr"', __CLASS__));
     }
     // Get MX Records to find smtp servers handling this domain
     if (getmxrr($domain, $mxhosts, $mxweight)) {
         for ($i = 0; $i < count($mxhosts); $i++) {
             $mxs[$mxhosts[$i]] = $mxweight[$i];
         }
         asort($mxs);
         $mailers = array_keys($mxs);
     } elseif (checkdnsrr($domain, 'A')) {
         $mailers[0] = gethostbyname($domain);
     } else {
         return false;
     }
     // Try to send to each mailserver
     $total = count($mailers);
     $ok = false;
     for ($n = 0; $n < $total; $n++) {
         $timeout = $this->timeout;
         $errno = 0;
         $errstr = 0;
         $sock = @fsockopen($mailers[$n], 25, $errno, $errstr, $timeout);
         if (!$sock) {
             continue;
         }
         $response = fgets($sock);
         stream_set_timeout($sock, $timeout);
         $meta = stream_get_meta_data($sock);
         $cmds = array("HELO localhost", sprintf("MAIL FROM: <%s>", $this->from), "RCPT TO: <{$email}>", "QUIT");
         if (!$meta['timed_out'] && !preg_match('/^2\\d\\d[ -]/', $response)) {
             break;
         }
         $success_ok = true;
         foreach ($cmds as $cmd) {
             fputs($sock, "{$cmd}\r\n");
             $response = fgets($sock, 4096);
             if (!$meta['timed_out'] && preg_match('/^5\\d\\d[ -]/', $response)) {
                 $success_ok = false;
                 break;
             }
         }
         fclose($sock);
         return $success_ok;
     }
     return false;
 }
开发者ID:vinyll,项目名称:sfValidatorRealEmailPlugin,代码行数:62,代码来源:RealEmailValidator.class.php


注:本文中的getmxrr函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。