Return to Snippet

Revision: 15151
at September 22, 2009 06:12 by brownrl


Updated Code
<?php
// FUNCTION: isValidEmail( $email )
// 
// return wether an email is valid.
//
// This is a hard core check cause we check the domain and we even check
// that the email is not one of the disposable email places.
//
// undisposable.net is a great service!
// tells wether or not the email you are getting
// is a mailinator or other disposable address
//
// Sorry but when a client pays 40,000 Euros for a web campaign
// they want real email addresses.
//
function isValidEmail( $email )
{
    // first thing to do is 
    // lets strip out the domain cause we are going to check the domain
    $domainname= explode("@",$email);
    $checkdomain= $domainname[1];
    
    // check if the filter works, then check that the domain is real
    if( filter_var( $email , FILTER_VALIDATE_EMAIL) &&  
        checkdnsrr( $checkdomain ) )
    {
        // ok it seems that we have real email address
        // now lets see if the email is in the disposable
        // email address lists.

        $url  = "http://www.undisposable.net/services/php/";
        $url .= "isDisposableEmail/?email=".addslashes($email);
        $res = @file_get_contents($url);
        $uns = @unserialize($res);
        if($uns['stat']=='ok')
        {
	    return ( $uns['email']['isdisposable'] != "yes" );
        }
        else
        {
            return false;
        }
     }
     else
     {
          return false;
     }
}
?>

Revision: 15150
at September 22, 2009 06:11 by brownrl


Updated Code
<?php
// FUNCTION: isValidEmail( $email )
// 
// return wether an email is valid.
//
// This is a hard core check cause we check the domain and we even check
// that the email is not one of the disposable email places.
//
// undisposable.net is a great service!
// tells wether or not the email you are getting
// is a mailinator or other disposable address
//
// Sorry but when a client pays 40,000 Euros for a web campaign
// they want real email addresses.
//
function isValidEmail( $email )
{
    // first thing to do is 
    // lets strip out the domain cause we are going to check the domain
    $domainname= explode("@",$email);
    $checkdomain= $domainname[1];
    
    // check if the filter works, then check that the domain is real
    if( filter_var( $email , FILTER_VALIDATE_EMAIL) &&  
        checkdnsrr( $checkdomain ) )
    {
        // ok it seems that we have real email address
        // now lets see if the email is in the disposable
        // email address lists.

        $url  = "http://www.undisposable.net/services/php/";
        $url .= "isDisposableEmail/?email=".addslashes($email);
        $res = @file_get_contents($url);
        $uns = @unserialize($res);
        if($uns['stat']=='ok')
        {
	    return $uns['email']['isValidEmail'];
        }
        else
        {
            return false;
        }
     }
     else
     {
          return false;
     }
}
?>

Revision: 15149
at June 26, 2009 05:50 by brownrl


Updated Code
<?php
// FUNCTION: isValidEmail( $email )
// 
// return wether an email is valid.
//
// This is a hard core check cause we check the domain and we even check
// that the email is not one of the disposable email places.
//
// undisposable.net is a great service!
// tells wether or not the email you are getting
// is a mailinator or other disposable address
//
// Sorry but when a client pays 40,000 Euros for a web campaign
// they want real email addresses.
//
function isValidEmail( $email )
{
    // first thing to do is 
    // lets strip out the domain cause we are going to check the domain
    $domainname= explode("@",$email);
    $checkdomain= $domainname[1];
    
    // check if the filter works, then check that the domain is real
    if( filter_var( $email , FILTER_VALIDATE_EMAIL) &&  
        checkdnsrr( $checkdomain ) )
    {
        // ok it seems that we have real email address
        // now lets see if the email is in the disposable
        // email address lists.

        $url  = "http://www.undisposable.net/services/php/";
        $url .= "isDisposableEmail/?email=".addslashes($email);
        $res = @file_get_contents($url);
        $uns = @unserialize($res);
        if($uns['stat']=='ok')
        {
	    return $uns['email']['isdisposable'];
        }
        else
        {
            return false;
        }
     }
     else
     {
          return false;
     }
}
?>

Revision: 15148
at June 26, 2009 05:41 by brownrl


Updated Code
<?php
// FUNCTION: isValidEmail( $email )
// 
// return wether an email is valid.
//
// This is a hard core check cause we check the domain and we even check
// that the email is not one of the disposable email places.
//
// undisposable.net is a great service!
// tells wether or not the email you are getting
// is a mailinator or other disposable address
//
// Sorry but when a client pays 40,000 Euros for a web campaign
// they want real email addresses.
//
function isValidEmail( $email )
{
    // first thing to do is 
    // lets strip out the domain cause we are going to check the domain
    $domainname= explode("@",$email);
    $checkdomain= $domainname[1];
    
    // check if the filter works, then check that the domain is real
    if( filter_var( $email , FILTER_VALIDATE_EMAIL) &&  
        checkdnsrr( $checkdomain ) )
    {
        // ok it seems that we have real email address
        // now lets see if the email is in the disposable
        // email address lists.

        $url  = "http://www.undisposable.net/services/php/";
        $url .= "isDisposableEmail/?email=".addslashes($email);
        $res = @file_get_contents($url);
        $uns = @unserialize($res);
        if($uns['stat']=='ok')
	        return $uns['email']['isdisposable'];
        else
	            return false;
	 }
	 else
	 {
	    return false;
	 }
}

?>

Revision: 15147
at June 26, 2009 05:39 by brownrl


Updated Code
<?php
// FUNCTION: validEmail( $email )
// 
// return wether an email is valid.
//
// This is a hard core check cause we check the domain and we even check
// that the email is not one of the disposable email places.
//
// undisposable.net is a great service!
// tells wether or not the email you are getting
// is a mailinator or other disposable address
//
// Sorry but when a client pays 40,000 Euros for a web campaign
// they want real email addresses.
//
function isValidEmail( $email )
{
    // first thing to do is 
    // lets strip out the domain cause we are going to check the domain
    $domainname= explode("@",$email);
    $checkdomain= $domainname[1];
    
    // check if the filter works, then check that the domain is real
    if( filter_var( $email , FILTER_VALIDATE_EMAIL) &&  
        checkdnsrr( $checkdomain ) )
    {
        // ok it seems that we have real email address
        // now lets see if the email is in the disposable
        // email address lists.

        $url  = "http://www.undisposable.net/services/php/";
        $url .= "isDisposableEmail/?email=".addslashes($email);
        $res = @file_get_contents($url);
        $uns = @unserialize($res);
        if($uns['stat']=='ok')
	        return $uns['email']['isdisposable'];
        else
	            return false;
	 }
	 else
	 {
	    return false;
	 }
}

?>

Revision: 15146
at June 26, 2009 05:38 by brownrl


Updated Code
<?php
// FUNCTION: validEmail( $email )
// 
// return wether an email is valid.
//
// This is a hard core check cause we check the domain and we even check
// that the email is not one of the disposable email places.
//
// undisposable.net is a great service!
// tells wether or not the email you are getting
// is a mailinator or other disposable address
//
// Sorry but when a client pays 40,000 Euros for a web campaign
// they want real email addresses.
//
function isValidEmail( $email )
{
    // first thing to do is 
    // lets strip out the domain cause we are going to check the domain
    $domainname= explode("@",$email);
    $checkdomain= $domainname[1];
    
    // check if the filter works, then check that the domain is real
    if( filter_var( $email , FILTER_VALIDATE_EMAIL) &&  
        checkdnsrr( $checkdomain ) )
    {
        // ok it seems that we have real email address
        // now lets see if the email is in the disposable
        // email address lists.
    
    	$url  = "http://www.undisposable.net/services/php/";
        $url .= "isDisposableEmail/?email=".addslashes($email);
        $res = @file_get_contents($url);
        $uns = @unserialize($res);
        if($uns['stat']=='ok')
	        return $uns['email']['isdisposable'];
        else
	            return false;
	 }
	 else
	 {
	    return false;
	 }
}

?>

Revision: 15145
at June 26, 2009 05:37 by brownrl


Initial Code
<?php
// FUNCTION: validEmail( $email )
// 
// return wether an email is valid.
//
// This is a hard core check cause we check the domain and we even check
// that the email is not one of the disposable email places.
//
// undisposable.net is a great service!
// tells wether or not the email you are getting
// is a mailinator or other disposable address
//
// Sorry but when a client pays 40,000 Euros for a web campaign
// they want real email addresses.
//
function isValidEmail( $email )
{
    // first thing to do is 
    // lets strip out the domain cause we are going to check the domain
    $domainname= explode("@",$email);
    $checkdomain= $domainname[1];
    
    // check if the filter works, then check that the domain is real
    if( filter_var( $email , FILTER_VALIDATE_EMAIL) ||  
        checkdnsrr( $checkdomain ) )
    {
        // ok it seems that we have real email address
        // now lets see if the email is in the disposable
        // email address lists.
    
    	$url  = "http://www.undisposable.net/services/php/";
        $url .= "isDisposableEmail/?email=".addslashes($email);
        $res = @file_get_contents($url);
        $uns = @unserialize($res);
        if($uns['stat']=='ok')
	        return $uns['email']['isdisposable'];
        else
	            return false;
	 }
	 else
	 {
	    return false;
	 }
}

?>

Initial URL
http://www.goingson.be

Initial Description
This is a slightly hard core email check. I work for clients that want real email addresses. They pay quite a bit of money so yes, I am going to give what they want...

Initial Title
PHP isValidEmail

Initial Tags
email, php, validation

Initial Language
PHP