Новичок
Профиль
Группа: Участник
Сообщений: 3
Регистрация: 7.9.2013
Репутация: нет Всего: нет
|
Здравствуйте, подскажите, пожалуйста, не могу понять в чем может быть дело: Пытаюсь проверить существует ли e-mail используя этот скрипт: http://htmlweb.ru/php/example/is_e-mail.phpНа локальном xampp сервере все работает замечательно, но после заливки на хостинг здесь Код | if ($connection = fsockopen ($mxhosts[0][$id], $port, $errno, $error, $this->timeout)) {
|
возникает ошибка "110 connection timed out" и, соответственно, email всегда определяется ненастоящим. Посмотреть работу скрипта+phpinfo можно здесь: http://daria2.tom.ru/Код index.php: Код | <?php define('DEBUG_OK', true);
class CCheckMail { var $timeout = 10; var $domain_rules = array("aol.com", "bigfoot.com", "brain.net.pk", "breathemail.net", "compuserve.com", "dialnet.co.uk", "glocksoft.com", "home.com", "msn.com", "rocketmail.com", "uu.net", "yahoo.com", "yahoo.de");
function _is_valid_email($email = "") { return preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $email); }
function _check_domain_rules($domain = "") { return in_array(strtolower($domain), $this->domain_rules); }
function execute($email = "") { if (!$this->_is_valid_email($email)) return false; $host = substr(strstr($email, '@'), 1);
if ($this->_check_domain_rules($host)) return false; $host .= ".";
if (getmxrr($host, $mxhosts[0], $mxhosts[1]) == true) array_multisort($mxhosts[1], $mxhosts[0]); else { $mxhosts[0] = $host; $mxhosts[1] = 10; } if (DEBUG_OK) print_r($mxhosts);
$port = 25; $localhost = $_SERVER['HTTP_HOST']; $sender = 'info@' . $localhost;
$result = false; $id = 0; while (!$result && $id < count($mxhosts[0])) { if (function_exists("fsockopen")) { if (DEBUG_OK) print_r($id . " " . $mxhosts[0][$id]); if ($connection = fsockopen($mxhosts[0][$id], $port, $errno, $error, $this->timeout)) { fputs($connection, "HELO $localhost\r\n"); // 250 $data = fgets($connection, 1024); $response = substr($data, 0, 1); if (DEBUG_OK) print_r($data); if ($response == '2') // 200, 250 etc. { fputs($connection, "MAIL FROM:<$sender>\r\n"); $data = fgets($connection, 1024); $response = substr($data, 0, 1); if (DEBUG_OK) print_r($data); if ($response == '2') // 200, 250 etc. { fputs($connection, "RCPT TO:<$email>\r\n"); $data = fgets($connection, 1024); $response = substr($data, 0, 1); if (DEBUG_OK) print_r($data); if ($response == '2') // 200, 250 etc. { fputs($connection, "data\r\n"); $data = fgets($connection, 1024); $response = substr($data, 0, 1); if (DEBUG_OK) print_r($data); if ($response == '2') // 200, 250 etc. { $result = true; } } } } fputs($connection, "QUIT\r\n"); fclose($connection); if ($result) return true; } } else break; $id++; } //while return false; } }
?>
<?php
if (isset($_POST['email'])) {
$str = $_POST['email']; $alter = new CCheckMail();
if ($alter->execute($str)) { $result = "Email " . $_POST['email'] . " is real"; } else { $result = "Email " . $_POST['email'] . " is fake"; } } else { $result = "Please fill email"; } ?> <div> Check if email exists: </div> <form method="post" action=""> <input type="text" name="email" value=""/> <input type="submit" value="Send"/> <div> <?php echo $result; ?> </div> </form> <?php phpinfo() ?>
|
|