SHARE
TWEET

Untitled

a guest Mar 31st, 2017 604 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class CCheckMail
  4. {
  5.   var $timeout = 10;
  6.   var $domain_rules = array ("aol.com", "bigfoot.com", "brain.net.pk", "breathemail.net",
  7.                 "compuserve.com", "dialnet.co.uk", "glocksoft.com", "home.com",
  8.                 "msn.com", "rocketmail.com", "uu.net", "yahoo.com", "yahoo.de");
  9.  
  10.   function _is_valid_email ($email = "")
  11.     { return preg_match('/^[.\w-]+@([\w-]+\.)+[a-zA-Z]{2,6}$/', $email); }
  12.  
  13.   function _check_domain_rules ($domain = "")
  14.     { return in_array (strtolower ($domain), $this->domain_rules); }
  15.  
  16.   function execute ($email = ""){
  17.     if (!$this->_is_valid_email ($email)) return false;
  18.     $host = substr (strstr ($email, '@'), 1);
  19.  
  20.     if ($this->_check_domain_rules ($host)) return false;
  21.     $host .= ".";
  22.  
  23.     if (getmxrr ($host, $mxhosts[0], $mxhosts[1]) == true)  array_multisort ($mxhosts[1], $mxhosts[0]);
  24.     else { $mxhosts[0] = $host;
  25.        $mxhosts[1] = 10;
  26.      }
  27.  
  28.     $port = 25;
  29.     $localhost = $_SERVER['HTTP_HOST'];
  30.     $sender = 'info@' . $localhost;
  31.  
  32.     $result = false;
  33.     $id = 0;
  34.     while (!$result && $id < count ($mxhosts[0]))
  35.     { if (function_exists ("fsockopen"))
  36.          {
  37.            if ($connection = fsockopen ($mxhosts[0][$id], $port, $errno, $error, $this->timeout))
  38.           {
  39.               fputs ($connection,"HELO $localhost\r\n");
  40.               $data = fgets ($connection,1024);
  41.               $response = substr ($data,0,1);
  42.               if ($response == '2')
  43.              {
  44.                 fputs ($connection,"MAIL FROM:<$sender>\r\n");
  45.                 $data = fgets($connection,1024);
  46.                 $response = substr ($data,0,1);
  47.                 if ($response == '2')
  48.                {
  49.                   fputs ($connection,"RCPT TO:<$email>\r\n");
  50.                   $data = fgets($connection,1024);
  51.                   $response = substr ($data,0,1);
  52.               if ($response == '2')
  53.                  {
  54.                     fputs ($connection,"data\r\n");
  55.                     $data = fgets($connection,1024);
  56.                     $response = substr ($data,0,1);
  57.                     if ($response == '2')
  58.                    { $result = true; }
  59.                      }
  60.                }
  61.              }
  62.           fputs ($connection,"QUIT\r\n");
  63.               fclose ($connection);
  64.               if ($result) return true;
  65.             }
  66.        }
  67.       else  break;
  68.       $id++;
  69.     }
  70.     return false;
  71. }
  72. }
  73.  
  74. $str='test@gmail.com';
  75. $alter=new CCheckMail();
  76. print "E-mail: ".$str." - ".($alter->execute($str)?'существует':'не существует');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top