5

Is there any possible way to find out if an email address exists in c#?

e.g. I have an email address like abcded@yahoo.com or asdf234@hotmail.com How can I do the validation?

smartali89
  • 209
  • 2
  • 8

6 Answers6

13

Once upon a time the Internet and the SMTP mail transfer protocol was invented. It was back in the good old days when everyone were nice and friendly, so a command was included in the SMTP protocol to verify email addresses - the VRFY command.

However, darkness came upon the Internet and brought spammers, worms and other evil, so the sysadmins of the Internet mail servers defended what was good by disabling the VRFY command.

So the short answer is: No.

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
7

The most obvious way is to send an email to the mail address and ask the recipient to reply or click a link.

Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • 1
    not only is it the most obvious way...it is the *only* way to prove that a user who registers is even close to the owner...and that assumes the email account isn't hacked, etc. – pearcewg Sep 09 '11 at 22:24
3

Basicly: you can't. There are servers that support finger (to verify that a particular user exists), but for Hotmail/Gmail it's just not possible. The mail will bounce though.

Anemoia
  • 7,928
  • 7
  • 46
  • 71
3

In general that's not possible. Which is why many websites have that to sign up you have to give your email address and they'll send a link where you have to go to that link to confirm that it's your email.

Hans Olsson
  • 54,199
  • 15
  • 94
  • 116
2

No way at all

If it's for a reason, such as signing up with verification, then someone will reply when you send.

Why do you want to do this?

gbn
  • 422,506
  • 82
  • 585
  • 676
  • Well, I am creating a emailing software and it has options to import emails as well, so I was wondering if it is possible to verify emails some how. – smartali89 May 01 '10 at 15:19
0

I'm a little bit late, but this might help someone Now you can check if the email exists or not.

Here is the code that I'm currently using on my website. You can use the same API in c#

    if(isEmialExist("EMAIL_ADDRESS_THAT"))
{
    echo "email exists, real email";
}
else
{
    echo "email doesn't exist";
}


function isEmialExist($emailAddress)
{
    if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
     return false; //invalid format
    }
    //now check if email really exist
    $postdata = http_build_query(array('api_key' => 'YOUR_API_KEY', 'email' => $emailAddress ));
    $url = "https://email-validator.com/api/v1.0/json";
    $opts = array('http' => array( 'method'  => 'POST', 'header'  => 'Content-Type: application/x-www-form-urlencoded', 'content' => $postdata ));
    
    $context  = stream_context_create($opts);
    $result = file_get_contents($url, false, $context);
    $data = json_decode($result, false);
    return $data->is_exists;
}

You can find more details here. https://email-validator.com/tutorial

Deluar Hossen
  • 595
  • 4
  • 6