本文整理汇总了PHP中getmxrr函数的典型用法代码示例。如果您正苦于以下问题:PHP getmxrr函数的具体用法?PHP getmxrr怎么用?PHP getmxrr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getmxrr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 `[email protected]` 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('[email protected]', '');
$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
示例16: getmxrr_portable
function getmxrr_portable($hostname = "", &$mxhosts, &$weight)
{
if (function_exists("getmxrr")) {
$result = getmxrr($hostname, $mxhosts, $weight);
} else {
$result = getmxrr_win($hostname, $mxhosts, $weight);
}
return $result;
}
开发者ID:romlg,项目名称:cms36,代码行数:9,代码来源:getmxrr.php
示例17: getmxrr
/**
* Static function that detects wether we're running windows or not and then either uses the native version of
* getmxrr or the alternative one. See getmxrr_windows below for more information.
*
* @param hostname The host for which we want to get the mx records.
* @param mxhosts The array we are going to fill with the mx records.
* @return Returns either true or false.
* @static
*/
function getmxrr($hostname, &$mxhosts)
{
if (OsDetect::isWindows()) {
// call the alternative version
return Dns::getmxrr_windows($hostname, $mxhosts);
} else {
// use the native version
return getmxrr($hostname, $mxhosts);
}
}
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:19,代码来源:dns.class.php
示例18: query
/**
* @param $host
* @return bool|array
*/
public function query($host)
{
if (getmxrr($host, $mx_records, $mx_weight) === false) {
$this->logger->debug("no MX records for host <{$host}> found");
return false;
}
$this->logger->debug("found " . count($mx_records) . " MX records for host <{$host}>");
// TODO: sort by weight
return $mx_records;
}
开发者ID:matiasdelellis,项目名称:mail,代码行数:14,代码来源:mxrecord.php
示例19: getMXRecords
/**
* Get MX records as IP addresses corresponding to a given
* Internet host name sorted by weight
* @param string $hostname Host name
* @return array Array with IP addresses
*/
function getMXRecords($hostname = '')
{
$ips = array();
if ($hostname != '') {
$records = array();
if (function_exists('getmxrr')) {
// Non-Windows platform
$mxhosts = null;
$weights = null;
if (false !== getmxrr($hostname, $mxhosts, $weights)) {
// Sort MX records by weight
$key_host = array();
foreach ($mxhosts as $key => $host) {
if (!isset($key_host[$weights[$key]])) {
$key_host[$weights[$key]] = array();
}
$key_host[$weights[$key]][] = $host;
}
unset($weights);
$records = array();
ksort($key_host);
foreach ($key_host as $hosts) {
foreach ($hosts as $host) {
$records[] = $host;
}
}
}
} else {
// Windows platform
$result = shell_exec('nslookup.exe -type=MX ' . $hostname);
if ($result != '') {
$matches = null;
if (preg_match_all("'^.*MX preference = (\\d{1,10}), mail exchanger = (.*)\$'simU", $result, $matches)) {
if (!empty($matches[2])) {
array_shift($matches);
array_multisort($matches[0], $matches[1]);
$records = $matches[1];
}
}
}
}
}
// Resolve host names
if (!empty($records)) {
foreach ($records as $rec) {
if ($resolved = gethostbynamel($rec)) {
foreach ($resolved as $ip) {
$ips[] = $ip;
}
}
}
}
return $ips;
}
开发者ID:MichaelFichtner,项目名称:RadioLaFamilia,代码行数:60,代码来源:tcp.class.php
示例20: is_email
function is_email($email, $use_dns = false)
{
if (!preg_match('/^[^\\s@]+@([a-z0-9-]+(\\.[a-z0-9-]+)+)$/i', $email, $matches)) {
return false;
} elseif ($use_dns) {
$tmp = array();
return getmxrr($matches[1], $tmp) || dns_get_record($matches[1], DNS_A);
} else {
return true;
}
}
开发者ID:jaz303,项目名称:zing,代码行数:11,代码来源:common.php
注:本文中的getmxrr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论