email scrub

#1
[eluser]infusionmedia[/eluser]
I am currently working on a list management application. I need to be able to segregate email data based on tld, non-tld, .gov, .edu, @spam... I guess my question is, has anybody else worked on something similar that can share some info and/or share some code that I can implement into this application? Thanks...

#2
[eluser]Leggy[/eluser]
You could do a regex to see if it a valid email e.g. (taken from the CI validator class)

Code:
preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)

There are better ways, i used to have a very good one but i have lost it since.

EDIT: I think i found it again, i made a few alterations to the code but here is the function:

Code:
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
    {
        // Seperate the username and domain to for checking
        list( $username, $domain ) = split( '@', $email );
        
        // Check if the domain has a mail handler
        if( @checkdnsrr( $domain, $rec_type ) ) return true;
        else return;
    }
}

#3
[eluser]infusionmedia[/eluser]
i appreciate the response. thanks.

#4
[eluser]infusionmedia[/eluser]
dude. you are the man, that was very helpful.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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