Checking for live email addresses in PHP
Checking for live email addresses in PHP
Written by Mike James   
Monday, 23 August 2010
Article Index
Checking for live email addresses in PHP
SMTP
Final Function

 

Banner

Using the function

To make everything fit together the complete function is:

function validateEmail($email){
list($name,$Domain) = split('@',$email);
$result=getmxrr($Domain,$POFFS);
if(!$result){$POFFS[0]=$Domain;}
$timeout=5;
$oldErrorLevel=
error_reporting(!E_WARNING);
$result=false;
foreach($POFFS as $PO )
{
$sock = fsockopen($PO, 25,
$errno, $errstr,  $timeout);
if($sock){
fwrite($sock, "HELO Mydomain.com\n");
$response= getResponse($sock);
fwrite($sock,
"MAIL FROM: <me@mydomain.com>\n");
$response= getResponse($sock);
fwrite($sock,"RCPT TO: <".$email.">\n");
$response= getResponse($sock);
list($code,$msg)=explode(' ',$response);
fwrite($sock,"RSET\n");
$response= getResponse($sock);
fwrite($sock,"quit\n");
fclose($sock);
if ($code == '250') {
$result= true;
break;
}
}
}
error_reporting($oldErrorLevel);
return $result;
}

To use the function you simply write something like:

if( validateEmail("name@domain")){
echo "valid";
}else{
echo "not valid";
}

There is a small possibility that if you use this sort of validation too often at any given site then you might be blacklisted, but as long as the frequency is low enough not to annoy it should be fine.

 

To access the code for this project, once you have registered,  click on CodeBin.

 

If you would like to be informed about new articles on I Programmer you can either follow us on Twitter, on Facebook or you can subscribe to our weekly newsletter.

 

Banner


The Minimum Spanning Tree - Prim's Algorithm

Finding the minimum spanning tree is one of the fundamental algorithms and it is important in computer science and practical programming. We take a look at the theory and the practice. 



Mandelbrot Zoomer in WPF

The Mandelbrot set is fun, but implementing a simple viewer in WPF can be a challenge.Here's a project to plot the Mandelbrot set and allow the user to zoom in on any area of interest.


Other Projects

<ASIN:0470872497>

<ASIN:1593271735>

<ASIN:1590599063>

<ASIN:0596514018>



Last Updated ( Monday, 23 August 2010 )
 
 

   
Banner
RSS feed of all content
I Programmer - full contents
Copyright © 2016 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.