The best way of verifying an email

#1
[eluser]Leggy[/eluser]
Well i have been fiddling with an old function recently and as many of you know checkdnsrr() doesn't work on windows servers so i decided to create an email checking function which checks the servers OS and if it is windows it uses fsockopen on port 25 to check. Here is my current function:

Code:
<?php
function check_email( $email, $rec_type = 'MX' )
{
    // Check if the domain is the correct format e.g. [email protected]
    if( [email protected]_match( '/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $email ) ) return;
    else
    {
        // Check if they included a rec type to check the server
        if( $rec_type == ( '' or null or false ) ) return true;
        else
        {
            // Seperate the username and domain to for checking
            list( $username, $domain ) = @split( '@', $email );
            
            // Check if the server is a Windows server
            if( @stristr( PHP_OS, 'Win' ) and PHP_OS != 'Darwin' )
            {
                // Check the socket (25)
                if( @fsockopen( $domain, 25, $errno, $errstr, 30 ) ) return true;
                else return;
            }
            else
            {
                // Check the DNS record
                if( @checkdnsrr( $domain, $rec_type ) == true ) return true;
                else return;
            }
        }
    }
}
?>

What would you recommend adding?

I was also considering modifying this so be able to use it in the verification class instead of its current email checker which only uses regex.


Messages In This Thread
The best way of verifying an email - by El Forum - 04-19-2008, 06:00 AM
The best way of verifying an email - by El Forum - 04-19-2008, 09:37 AM
The best way of verifying an email - by El Forum - 04-19-2008, 12:44 PM
The best way of verifying an email - by El Forum - 04-19-2008, 05:24 PM
The best way of verifying an email - by El Forum - 04-20-2008, 03:30 AM
The best way of verifying an email - by El Forum - 04-21-2008, 10:37 AM
The best way of verifying an email - by El Forum - 04-21-2008, 12:20 PM
The best way of verifying an email - by El Forum - 04-21-2008, 03:51 PM
The best way of verifying an email - by El Forum - 04-22-2008, 11:20 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.