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.
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.
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.
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.
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.
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.
^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$
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
}