Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. namespace AppExternalClasses;
  2.  
  3. use AppExternalClassesCCheckMail;
  4.  
  5. $pricesClass = new CCheckMail();
  6. $email2 = ['myemail@gmail.com'];
  7. $prices = $pricesClass->execute ($email2);
  8. return view('pages.home', compact('prices'));
  9.  
  10. <?php
  11. namespace AppExternalClasses;
  12. /*
  13. * This script was writed by Setec Astronomy - setec@freemail.it
  14. *
  15. * This script is distributed under the GPL License
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * http://www.gnu.org/licenses/gpl.txt
  23. *
  24. */
  25. define ('DEBUG_OK', false);
  26. class CCheckMail
  27. {
  28. var $timeout = 10;
  29. var $domain_rules = array ("aol.com", "bigfoot.com", "brain.net.pk", "breathemail.net",
  30. "compuserve.com", "dialnet.co.uk", "glocksoft.com", "home.com",
  31. "msn.com", "rocketmail.com", "uu.net", "yahoo.com", "yahoo.de");
  32.  
  33. function _is_valid_email ($email = "")
  34. { return preg_match('/^[.w-]+@([w-]+.)+[a-zA-Z]{2,6}$/', $email); }
  35.  
  36. function _check_domain_rules ($domain = "")
  37. { return in_array (strtolower ($domain), $this->domain_rules); }
  38.  
  39. function execute ($email = "")
  40. {
  41. if (!$this->_is_valid_email ($email))
  42. { return false; }
  43.  
  44. $host = substr (strstr ($email, '@'), 1);
  45.  
  46. if ($this->_check_domain_rules ($host))
  47. { return false; }
  48.  
  49. $host .= ".";
  50.  
  51. if (getmxrr ($host, $mxhosts[0], $mxhosts[1]) == true)
  52. { array_multisort ($mxhosts[1], $mxhosts[0]); }
  53. else
  54. {
  55. $mxhosts[0] = $host;
  56. $mxhosts[1] = 10;
  57. }
  58. if (DEBUG_OK) { print_r ($mxhosts); }
  59.  
  60. $port = 25;
  61. $localhost = $_SERVER['HTTP_HOST'];
  62. $sender = 'info@' . $localhost;
  63.  
  64. $result = false;
  65. $id = 0;
  66. while (!$result && $id < count ($mxhosts[0]))
  67. {
  68. if (function_exists ("fsockopen"))
  69. {
  70. if (DEBUG_OK) { print_r ($id . " " . $mxhosts[0][$id]); }
  71. if ($connection = fsockopen ($mxhosts[0][$id], $port, $errno, $error, $this->timeout))
  72. {
  73. fputs ($connection,"HELO $localhostrn"); // 250
  74. $data = fgets ($connection,1024);
  75. $response = substr ($data,0,1);
  76. if (DEBUG_OK) { print_r ($data); }
  77.  
  78. if ($response == '2') // 200, 250 etc.
  79. {
  80. fputs ($connection,"MAIL FROM:<$sender>rn");
  81. $data = fgets($connection,1024);
  82. $response = substr ($data,0,1);
  83. if (DEBUG_OK) { print_r ($data); }
  84.  
  85. if ($response == '2') // 200, 250 etc.
  86. {
  87. fputs ($connection,"RCPT TO:<$email>rn");
  88. $data = fgets($connection,1024);
  89. $response = substr ($data,0,1);
  90. if (DEBUG_OK) { print_r ($data); }
  91.  
  92. if ($response == '2') // 200, 250 etc.
  93. {
  94. fputs ($connection,"datarn");
  95. $data = fgets($connection,1024);
  96. $response = substr ($data,0,1);
  97. if (DEBUG_OK) { print_r ($data); }
  98.  
  99. if ($response == '2') // 200, 250 etc.
  100. { $result = true; }
  101. }
  102. }
  103. }
  104.  
  105. fputs ($connection,"QUITrn");
  106. fclose ($connection);
  107. if ($result) { return true; }
  108. }
  109. }
  110. else
  111. { break; }
  112. $id++;
  113. }
  114. return false;
  115. }
  116. }
  117. ?>
  118.  
  119. <?php
  120. /*
  121. * This script was writed by Setec Astronomy - setec@freemail.it
  122. *
  123. * On row 41 of CCheckMail.php substitute the following line
  124. *
  125. * if (getmxrr ($host, $mxhosts[0], $mxhosts[1]) == true)
  126. *
  127. * with
  128. *
  129. * if (getmxrr_portable ($host, $mxhosts[0], $mxhosts[1]) == true)
  130. *
  131. * to have a fully working portable (*nix and Windows) CCheckMail class
  132. *
  133. * This script is distributed under the GPL License
  134. *
  135. * This program is distributed in the hope that it will be useful,
  136. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  137. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  138. * GNU General Public License for more details.
  139. *
  140. * http://www.gnu.org/licenses/gpl.txt
  141. *
  142. */
  143. function getmxrr_win ($hostname = "", &$mxhosts, &$weight)
  144. {
  145. $weight = array();
  146. $mxhosts = array();
  147. $result = false;
  148.  
  149.  
  150. $command = "nslookup -type=mx " . escapeshellarg ($hostname);
  151. exec ($command, $result);
  152. $i = 0;
  153. while (list ($key, $value) = each ($result))
  154. {
  155. if (strstr ($value, "mail exchanger"))
  156. { $nslookup[$i] = $value; $i++; }
  157. }
  158.  
  159. while (list ($key, $value) = each ($nslookup))
  160. {
  161. $temp = explode ( " ", $value );
  162. $mx[$key][0] = substr($temp[3],0,-1);
  163. $mx[$key][1] = $temp[7];
  164. $mx[$key][2] = gethostbyname ( $temp[7] );
  165. }
  166.  
  167. array_multisort ($mx);
  168.  
  169. foreach ($mx as $value)
  170. {
  171. $mxhosts[] = $value[1];
  172. $weight[] = $value[0];
  173. }
  174.  
  175. $result = count ($mxhosts) > 0;
  176. return $result;
  177. }
  178.  
  179. function getmxrr_portable ($hostname = "", &$mxhosts, &$weight)
  180. {
  181. if (function_exists ("getmxrr"))
  182. { $result = getmxrr ($hostname, $mxhosts, $weight); }
  183. else
  184. { $result = getmxrr_win ($hostname, $mxhosts, $weight); }
  185. return $result;
  186. }
  187. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement