-1

How to Check Email is validate or not ?

(Example :- abc@yahoo.com -> Ok
abc@yahoo.con ->wrong)

I want to check validation for all world class level email address.

Priyank Gandhi
  • 1,257
  • 1
  • 16
  • 29
Nikunj Patel
  • 14
  • 1
  • 2
  • 8
  • 2
    did you mean check all domain ?. – Mayur Patel Apr 25 '13 at 04:28
  • it's worth pointing out that there are hundreds of new top level domains being launched very soon. `.con` is not one of the new ones, but your code *does* need to be aware of the new TLDs. Anything could be valid. Some examples [from the list](https://gtldresult.icann.org/application-result/applicationstatus/viewstatus) include `.bike`, `.baby`, `.inc`, and hundreds more. Also, `.co` and `.cm` are valid extensions, so even though they're common typos of `.com`, you can't automatically assume they're incorrect. – Spudley Apr 25 '13 at 09:54

5 Answers5

3

You could try to use reverse email lookup services, but those won't be very reliable and many email providers deny reverse lookup requests. So I think your best bet is to first check that the email address is formatted correctly, then check the host domain exists, and then just send a verification email.

Tom
  • 4,422
  • 3
  • 24
  • 36
1

To check if a string is a valid email you can use Regex,

Ex :

bool isEmail = Regex.IsMatch(emailString, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|asia|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel)\b)\Z", RegexOptions.IgnoreCase);

To validate if a mailbox exists or not , follow this article.

Verify an Email Address

When you send an email to someone, the message goes to an SMTP server which then looks for the MX (Mail Exchange) records of the email recipient’s domain.

For instance, when you send an email to hello@gmail.com, the mail server will try to find the MX records for the gmail.com domain. If the records exist, the next step would be to determine whether that email username (hello in our example) is present or not.

Using a similar logic, we can verify an email address from the computer without actually sending a test message.

doing the same thing in .Net can be a tedious task.

Parimal Raj
  • 20,189
  • 9
  • 73
  • 110
0

It's a pointless exercise. The only real way to do this validation is to send someone an email and require a response to verify that the email is in use. I also don't understand your example, abc@yahoo.com is not valid but :-abc@yahoo.com is? What? Do some simple validation that your user entered it correctly, that's it.

KyleM
  • 4,445
  • 9
  • 46
  • 78
  • abc@yahoo.com is right email address but abc@yahoo.con is not right. I ask you how can i check it is valid or not ? – Nikunj Patel Apr 25 '13 at 04:52
0
^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$
Mayur Patel
  • 245
  • 1
  • 12
0

You could also use the MailAddress Class to validate the string and create a extension.

public static bool IsValidEmailAddress(this string email)
{
    try
    {
        var addr = new MailAddress(email);
        return true;
    }
    catch
    {
        return false;
    }
}

Usage:

string email = "test@yahoo.com";
if (email.IsValidEmailAddress())
{
 //TODO: Is email
}
spajce
  • 7,044
  • 5
  • 29
  • 44