• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validate email really exists

#6
I used to use a function like this, but it proves to be too unreliable so I discontinued using it:


Code:
public function _email_core($email)
{
    # Check email syntax with regex
    $emailClean = 1;
    if (preg_match('/^([a-zA-Z0-9\._\+-]+)\@((\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,7}|[0-9]{1,3})(\]?))$/', $email, $matches))
    {
        $user = $matches[1];
        $domain = $matches[2];
        # Check availability of DNS MX records
        if (function_exists('getmxrr'))
        {
            # Construct array of available mailservers
            if(getmxrr($domain, $mxhosts, $mxweight))
            {
                for($i=0;$i<count($mxhosts);$i++)
                {
                    $mxs[$mxhosts[$i]] = $mxweight[$i];
                }
                asort($mxs);
                $mailers = array_keys($mxs);
            }
            elseif(checkdnsrr($domain, 'A'))
            {
                $mailers[0] = gethostbyname($domain);
            }
            else
            {
                $mailers=array();
            }
            $total = count($mailers);
            if($total <= 0)
            {
                //$emailClean = 0;
                return FALSE;
            }
        }
        else
        {
            //debug only for localhost (wampserver)
            return TRUE;
        }
    }
    else
    {
        return FALSE;
    }
    return TRUE;
}
Reply


Messages In This Thread
Validate email really exists - by slipdiegoknot - 05-18-2016, 05:22 PM
RE: Validate email really exists - by cartalot - 05-18-2016, 06:07 PM
RE: Validate email really exists - by orionstar - 05-18-2016, 07:44 PM
RE: Validate email really exists - by CINewb - 05-19-2016, 02:43 AM
RE: Validate email really exists - by skunkbad - 05-19-2016, 01:53 PM
RE: Validate email really exists - by skunkbad - 05-19-2016, 05:26 PM
RE: Validate email really exists - by PaulD - 05-19-2016, 02:56 PM
RE: Validate email really exists - by acsv - 05-19-2016, 03:37 PM
RE: Validate email really exists - by Andy N - 05-23-2016, 08:30 AM
RE: Validate email really exists - by wolf - 09-25-2019, 11:13 PM
RE: Validate email really exists - by InsiteFX - 09-27-2019, 08:28 AM
RE: Validate email really exists - by valval - 10-29-2019, 08:06 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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