<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: SMTP check code in PHP &#8211; Download</title>
	<atom:link href="http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/</link>
	<description>Little words of wisdom</description>
	<lastBuildDate>Fri, 03 Feb 2012 09:46:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: ssss</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-62775</link>
		<dc:creator>ssss</dc:creator>
		<pubDate>Sun, 20 Nov 2011 21:59:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-62775</guid>
		<description>hohoh</description>
		<content:encoded><![CDATA[<p>hohoh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hannoud</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-62330</link>
		<dc:creator>hannoud</dc:creator>
		<pubDate>Fri, 18 Nov 2011 13:16:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-62330</guid>
		<description>Hi there.
First i want to thank you for this great article.
I&#039;m trying to use this code but i am always getting this results:
array(2) { [&quot;ysf654654654654564644@hotmail.com&quot;]=&gt; bool(false) [&quot;ysf44@hotmail.com&quot;]=&gt; bool(false) } 
ysf654654654654564644@hotmail.com,ysf44@hotmail.com is valid 

even tho the 1st email is not valid, can anyone help me please?</description>
		<content:encoded><![CDATA[<p>Hi there.<br />
First i want to thank you for this great article.<br />
I&#8217;m trying to use this code but i am always getting this results:<br />
array(2) { ["ysf654654654654564644@hotmail.com"]=&gt; bool(false) ["ysf44@hotmail.com"]=&gt; bool(false) }<br />
<a href="mailto:ysf654654654654564644@hotmail.com">ysf654654654654564644@hotmail.com</a>,ysf44@hotmail.com is valid </p>
<p>even tho the 1st email is not valid, can anyone help me please?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unux</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-52122</link>
		<dc:creator>unux</dc:creator>
		<pubDate>Sat, 01 Oct 2011 02:23:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-52122</guid>
		<description>Hey,
I&#039;m not if this solves my problem. Say,I have a web and I have a registration form which I want users to fill their e-mails. Does the codes you provide validate and verify the e-mails AUTOMATICALLY?
 If not so, how can I go around that? 
Thanks,in advance.</description>
		<content:encoded><![CDATA[<p>Hey,<br />
I&#8217;m not if this solves my problem. Say,I have a web and I have a registration form which I want users to fill their e-mails. Does the codes you provide validate and verify the e-mails AUTOMATICALLY?<br />
 If not so, how can I go around that?<br />
Thanks,in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sanil</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-46154</link>
		<dc:creator>Sanil</dc:creator>
		<pubDate>Thu, 01 Sep 2011 21:43:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-46154</guid>
		<description>I tried the script and it works well on linux. However, I have some issues with making it work on Windows. Anything that I am missing? I added DNS.php to the Net folder inside PEAR folder. Please let me know if anyone has any idea about this issue.</description>
		<content:encoded><![CDATA[<p>I tried the script and it works well on linux. However, I have some issues with making it work on Windows. Anything that I am missing? I added DNS.php to the Net folder inside PEAR folder. Please let me know if anyone has any idea about this issue.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: omer</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-45669</link>
		<dc:creator>omer</dc:creator>
		<pubDate>Thu, 25 Aug 2011 22:32:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-45669</guid>
		<description>good script</description>
		<content:encoded><![CDATA[<p>good script</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: How to check if an email address exists without sending an email? &#124; Web Developers articles, tutorials, help</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-38950</link>
		<dc:creator>How to check if an email address exists without sending an email? &#124; Web Developers articles, tutorials, help</dc:creator>
		<pubDate>Tue, 24 May 2011 10:29:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-38950</guid>
		<description>[...] 1) SMTP check code in PHP &#8211; DOWNLOAD [...]</description>
		<content:encoded><![CDATA[<p>[...] 1) SMTP check code in PHP &#8211; DOWNLOAD [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warner</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-36840</link>
		<dc:creator>Warner</dc:creator>
		<pubDate>Thu, 21 Apr 2011 20:32:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-36840</guid>
		<description>Did anyone ever figure out this code?  I&#039;m trying to also figure out where to put the email you are trying to validate but I&#039;m not able to find where to put it.  Also, Warren, I pasted your code into Dreamweaver and got tons of red flags for &quot;,&#039;, and {} out of place.  If someone could PLEASE help me I&#039;d appreciate it.</description>
		<content:encoded><![CDATA[<p>Did anyone ever figure out this code?  I&#8217;m trying to also figure out where to put the email you are trying to validate but I&#8217;m not able to find where to put it.  Also, Warren, I pasted your code into Dreamweaver and got tons of red flags for &#8220;,&#8217;, and {} out of place.  If someone could PLEASE help me I&#8217;d appreciate it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Warren</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-29312</link>
		<dc:creator>Warren</dc:creator>
		<pubDate>Wed, 19 Jan 2011 15:25:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-29312</guid>
		<description>Hi 

It tool me a while but have found out how to use this class I had to make a tweek.

setEmails($emails);
  }
  if ($sender) {
   $this-&gt;setSenderEmail($sender);
  }
 }

 function _parseEmail($email) {
  $parts = explode(&#039;@&#039;, $email);
 $domain = array_pop($parts);
 $user= implode(&#039;@&#039;, $parts);
 return array($user, $domain);
 }

 /**
  * Set the Emails to validate
  * @param $emails Array List of Emails
  */
 function setEmails($emails) {
  foreach($emails as $email) {
  list($user, $domain) = $this-&gt;_parseEmail($email);
  if (!isset($this-&gt;domains[$domain])) {
    $this-&gt;domains[$domain] = array();
  }
  $this-&gt;domains[$domain][] = $user;
 }
 }

 /**
  * Set the Email of the sender/validator
  * @param $email String
  */
 function setSenderEmail($email) {
 $parts = $this-&gt;_parseEmail($email);
 $this-&gt;from_user = $parts[0];
 $this-&gt;from_domain = $parts[1];
 }

 /**
 * Validate Email Addresses
 * @param String $emails Emails to validate (recipient emails)
 * @param String $sender Sender&#039;s Email
 * @return Array Associative List of Emails and their validation results
 */
 function validate($emails = false, $sender = false) {

  $results = array();

  if ($emails) {
   $this-&gt;setEmails($emails);
  }
  if ($sender) {
   $this-&gt;setSenderEmail($sender);
  }
  $i=0;
  // query the MTAs on each Domain
  foreach($this-&gt;domains as $domain=&gt;$users) {

  $mxs = array();

   // retrieve SMTP Server via MX query on domain
   list($hosts, $mxweights) = $this-&gt;queryMX($domain);
   if(count($hosts) &gt; 0){
       // retrieve MX priorities
       for($n=0; $n domain);

       $this-&gt;debug(print_r($mxs, 1));

       $timeout = $this-&gt;max_conn_time/count($hosts);

       // try each host
       while(list($host) = each($mxs)) {
        // connect to SMTP server
        $this-&gt;debug(&quot;try $host:$this-&gt;port\n&quot;);
        if ($this-&gt;sock = fsockopen($host, $this-&gt;port, $errno, $errstr, (float) $timeout)) {
         stream_set_timeout($this-&gt;sock, $this-&gt;max_read_time);
         break;
        }
       }

       // did we get a TCP socket
       if ($this-&gt;sock) {
        $reply = fread($this-&gt;sock, 2082);
        $this-&gt;debug(&quot;&lt;&lt;send(&quot;HELO &quot;.$this-&gt;from_domain);
        // tell of sender
        $this-&gt;send(&quot;MAIL FROM: from_user.&#039;@&#039;.$this-&gt;from_domain.&quot;&gt;&quot;);

        // ask for each recepient on this domain
        foreach($users as $user) {

         // ask of recepient
         $reply = $this-&gt;send(&quot;RCPT TO: &quot;);

          // get code and msg from response
         preg_match(&#039;/^([0-9]{3}) /ims&#039;, $reply, $matches);
         $code = isset($matches[1]) ? $matches[1] : &#039;&#039;;

         if ($code == &#039;250&#039;) {
          // you received 250 so the email address was accepted
          $results[$user.&#039;@&#039;.$domain] = true;
         } elseif ($code == &#039;451&#039; &#124;&#124; $code == &#039;452&#039;) {
       // you received 451 so the email address was greylisted (or some temporary error occured on the MTA) - so assume is ok
       $results[$user.&#039;@&#039;.$domain] = true;
         } else {
          $results[$user.&#039;@&#039;.$domain] = false;
         }

        }

        // quit
        $this-&gt;send(&quot;quit&quot;);
        // close socket
        fclose($this-&gt;sock);

       }
   }else{


          $results[$this-&gt;domains[$domain][$i].&#039;@&#039;.$domain] = false;



   }
   $i++;
  }
 return $results;
 }


 function send($msg) {
  fwrite($this-&gt;sock, $msg.&quot;\r\n&quot;);

  $reply = fread($this-&gt;sock, 2082);

  $this-&gt;debug(&quot;&gt;&gt;&gt;\n$msg\n&quot;);
  $this-&gt;debug(&quot;&lt;&lt;debug = $this-&gt;debug;
  // nameservers to query
  $resolver-&gt;nameservers = $this-&gt;nameservers;
  $resp = $resolver-&gt;query($domain, &#039;MX&#039;);
  if ($resp) {
   foreach($resp-&gt;answer as $answer) {
    $hosts[] = $answer-&gt;exchange;
    $mxweights[] = $answer-&gt;preference;
   }
  }

  }
 return array($hosts, $mxweights);
 }

 /**
  * Simple function to replicate PHP 5 behaviour. http://php.net/microtime
  */
 function microtime_float() {
  list($usec, $sec) = explode(&quot; &quot;, microtime());
  return ((float)$usec + (float)$sec);
 }

 function debug($str) {
  if ($this-&gt;debug) {
   echo htmlentities($str);
  }
 }

}
  $checkEmail = new SMTP_validateEmail();
 $check = $checkEmail-&gt;validate(array(&quot;wtucke01@hotmail.com&quot;), &#039;warren.tucker@o-bit.net&#039;);
   print $check[&quot;wtucke01@hotmail.com&quot;];</description>
		<content:encoded><![CDATA[<p>Hi </p>
<p>It tool me a while but have found out how to use this class I had to make a tweek.</p>
<p>setEmails($emails);<br />
  }<br />
  if ($sender) {<br />
   $this-&gt;setSenderEmail($sender);<br />
  }<br />
 }</p>
<p> function _parseEmail($email) {<br />
  $parts = explode(&#8216;@&#8217;, $email);<br />
 $domain = array_pop($parts);<br />
 $user= implode(&#8216;@&#8217;, $parts);<br />
 return array($user, $domain);<br />
 }</p>
<p> /**<br />
  * Set the Emails to validate<br />
  * @param $emails Array List of Emails<br />
  */<br />
 function setEmails($emails) {<br />
  foreach($emails as $email) {<br />
  list($user, $domain) = $this-&gt;_parseEmail($email);<br />
  if (!isset($this-&gt;domains[$domain])) {<br />
    $this-&gt;domains[$domain] = array();<br />
  }<br />
  $this-&gt;domains[$domain][] = $user;<br />
 }<br />
 }</p>
<p> /**<br />
  * Set the Email of the sender/validator<br />
  * @param $email String<br />
  */<br />
 function setSenderEmail($email) {<br />
 $parts = $this-&gt;_parseEmail($email);<br />
 $this-&gt;from_user = $parts[0];<br />
 $this-&gt;from_domain = $parts[1];<br />
 }</p>
<p> /**<br />
 * Validate Email Addresses<br />
 * @param String $emails Emails to validate (recipient emails)<br />
 * @param String $sender Sender&#8217;s Email<br />
 * @return Array Associative List of Emails and their validation results<br />
 */<br />
 function validate($emails = false, $sender = false) {</p>
<p>  $results = array();</p>
<p>  if ($emails) {<br />
   $this-&gt;setEmails($emails);<br />
  }<br />
  if ($sender) {<br />
   $this-&gt;setSenderEmail($sender);<br />
  }<br />
  $i=0;<br />
  // query the MTAs on each Domain<br />
  foreach($this-&gt;domains as $domain=&gt;$users) {</p>
<p>  $mxs = array();</p>
<p>   // retrieve SMTP Server via MX query on domain<br />
   list($hosts, $mxweights) = $this-&gt;queryMX($domain);<br />
   if(count($hosts) &gt; 0){<br />
       // retrieve MX priorities<br />
       for($n=0; $n domain);</p>
<p>       $this-&gt;debug(print_r($mxs, 1));</p>
<p>       $timeout = $this-&gt;max_conn_time/count($hosts);</p>
<p>       // try each host<br />
       while(list($host) = each($mxs)) {<br />
        // connect to SMTP server<br />
        $this-&gt;debug(&#8220;try $host:$this-&gt;port\n&#8221;);<br />
        if ($this-&gt;sock = fsockopen($host, $this-&gt;port, $errno, $errstr, (float) $timeout)) {<br />
         stream_set_timeout($this-&gt;sock, $this-&gt;max_read_time);<br />
         break;<br />
        }<br />
       }</p>
<p>       // did we get a TCP socket<br />
       if ($this-&gt;sock) {<br />
        $reply = fread($this-&gt;sock, 2082);<br />
        $this-&gt;debug(&#8220;&lt;&lt;send(&#8220;HELO &#8220;.$this-&gt;from_domain);<br />
        // tell of sender<br />
        $this-&gt;send(&#8220;MAIL FROM: from_user.&#8217;@&#8217;.$this-&gt;from_domain.&#8221;&gt;&#8221;);</p>
<p>        // ask for each recepient on this domain<br />
        foreach($users as $user) {</p>
<p>         // ask of recepient<br />
         $reply = $this-&gt;send(&#8220;RCPT TO: &#8220;);</p>
<p>          // get code and msg from response<br />
         preg_match(&#8216;/^([0-9]{3}) /ims&#8217;, $reply, $matches);<br />
         $code = isset($matches[1]) ? $matches[1] : &#8221;;</p>
<p>         if ($code == &#8217;250&#8242;) {<br />
          // you received 250 so the email address was accepted<br />
          $results[$user.'@'.$domain] = true;<br />
         } elseif ($code == &#8217;451&#8242; || $code == &#8217;452&#8242;) {<br />
       // you received 451 so the email address was greylisted (or some temporary error occured on the MTA) &#8211; so assume is ok<br />
       $results[$user.'@'.$domain] = true;<br />
         } else {<br />
          $results[$user.'@'.$domain] = false;<br />
         }</p>
<p>        }</p>
<p>        // quit<br />
        $this-&gt;send(&#8220;quit&#8221;);<br />
        // close socket<br />
        fclose($this-&gt;sock);</p>
<p>       }<br />
   }else{</p>
<p>          $results[$this-&gt;domains[$domain][$i].&#8217;@&#8217;.$domain] = false;</p>
<p>   }<br />
   $i++;<br />
  }<br />
 return $results;<br />
 }</p>
<p> function send($msg) {<br />
  fwrite($this-&gt;sock, $msg.&#8221;\r\n&#8221;);</p>
<p>  $reply = fread($this-&gt;sock, 2082);</p>
<p>  $this-&gt;debug(&#8220;&gt;&gt;&gt;\n$msg\n&#8221;);<br />
  $this-&gt;debug(&#8220;&lt;&lt;debug = $this-&gt;debug;<br />
  // nameservers to query<br />
  $resolver-&gt;nameservers = $this-&gt;nameservers;<br />
  $resp = $resolver-&gt;query($domain, &#8216;MX&#8217;);<br />
  if ($resp) {<br />
   foreach($resp-&gt;answer as $answer) {<br />
    $hosts[] = $answer-&gt;exchange;<br />
    $mxweights[] = $answer-&gt;preference;<br />
   }<br />
  }</p>
<p>  }<br />
 return array($hosts, $mxweights);<br />
 }</p>
<p> /**<br />
  * Simple function to replicate PHP 5 behaviour. <a href="http://php.net/microtime" rel="nofollow">http://php.net/microtime</a><br />
  */<br />
 function microtime_float() {<br />
  list($usec, $sec) = explode(&#8221; &#8220;, microtime());<br />
  return ((float)$usec + (float)$sec);<br />
 }</p>
<p> function debug($str) {<br />
  if ($this-&gt;debug) {<br />
   echo htmlentities($str);<br />
  }<br />
 }</p>
<p>}<br />
  $checkEmail = new SMTP_validateEmail();<br />
 $check = $checkEmail-&gt;validate(array(&#8220;wtucke01@hotmail.com&#8221;), &#8216;warren.tucker@o-bit.net&#8217;);<br />
   print $check["wtucke01@hotmail.com"];</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: colin enzer</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-21408</link>
		<dc:creator>colin enzer</dc:creator>
		<pubDate>Wed, 29 Sep 2010 12:06:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-21408</guid>
		<description>Does this exist?</description>
		<content:encoded><![CDATA[<p>Does this exist?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yrcreddy</title>
		<link>http://www.webdigi.co.uk/blog/2009/how-to-check-if-an-email-address-exists-without-sending-an-email/smtpvalidateclassphp/comment-page-1/#comment-17249</link>
		<dc:creator>yrcreddy</dc:creator>
		<pubDate>Wed, 23 Jun 2010 18:54:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.webdigi.co.uk/blog/wp-content/uploads/2009/01/smtpvalidateclassphp.txt#comment-17249</guid>
		<description>hi its good but how to know the smtp_server ipadresss can any one tell me with examples of placing 
appreciate and thanks in advance.......</description>
		<content:encoded><![CDATA[<p>hi its good but how to know the smtp_server ipadresss can any one tell me with examples of placing<br />
appreciate and thanks in advance&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

