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

#1
Hi is there a way to know if a email address really exists?
not format I mean if the email address would really get an email sent to it

thanks in advance
Reply

#2
i think the only thing you could really do is send them an email to confirm. they don't have to open it - there are services that will record whether or not it was valid in terms of it being received by a valid service or not.
Reply

#3
You have to mimic the SMTP server's behaviour until the "RCPT TO: xxxx" command, if response contains "Ok" then the email address is exists.

But it can be more complex, I think you should google it... I just found a very good resource: https://www.webdigi.co.uk/blog/2009/how-...-an-email/
Reply

#4
You can also use PHP's getmxrr() function to see if a hostname has an MX record:

if (getmxrr('hostname.com')) {
echo 'Has at least one MX record so send an email';
}

However this doesn't guarantee an address exists, only that a hostname is setup to receive email.
Reply

#5
This is one of the "holy grail" goals for we coders. Sadly, there is no "easy" way to do this.

So, you can do it the hard way. This PDF contains a lot of information about the process and how to implement it. It also contains some VERY VALID WARNINGS about what consequences you can expect if you do too much. DO read it through:

https://assets.hubexchange.com/towerdata...dation.pdf

NOTE that there are a huge number of commercial services which provide this utility. That should tell you that it is complex enough to make it easier to pay for third party verification than to write your own. Yes, you can write your own utility, but there is significant overhead to your system and you (or your client) must be willing to accept the task of administrating the email validation system...

Disclaimer, I do not operate such a verification system and am not affiliated with any such systems.
CI 3.1 Kubuntu 19.04 Apache 5.x  Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply

#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

#7
Brian,  If I read your code correctly, it checks for the MX record on the mail server, but not for the existence of the actual email account?
CI 3.1 Kubuntu 19.04 Apache 5.x&nbsp; Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply

#8
Just tonight I was having a look at hosting websites and I noticed one did exactly that. Normally I start plodding through registrations systems with nonsense like Name: asdfasdfasdf Email:asdfasd@asdf.co.uk etc etc but this one site knew it was a nonsense email. In the end I made up one that was almost certainly taken by someone and it passed but the process was really impressive, and I thought at the time - how do they do that?

I do not want to advertise the site but I think it was on: "e h o s t . c o m" - an example of a really impressive sign up process.

I just googled it and mailgun.com looks really good, does anyone know of any others, or has anyone used anything like this before?

PS Thinking about it, it is not as useful as I thought it might be (certainly for spam protection it is) but still have to validate ownership of the email for registration so still have to send an email for verification.
Reply

#9
One of the reasons it is so difficult to check if an email exists (without sending an email) is that spammers could then brute force every valid email for a domain.
Reply

#10
(05-19-2016, 02:17 PM)twpmarketing Wrote: Brian,  If I read your code correctly, it checks for the MX record on the mail server, but not for the existence of the actual email account?

Sounds right.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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