In my application I validate a email domain like this:
public bool DomainValid(string domainName)
{
try
{
IPHostEntry entry = Dns.GetHostEntry(domainName);
return true;
}
catch (Exception)
{
return false;
}
}
The method is good, but not on every cases, like 'mpg.ro' is a valid email domain but it catches an Exception.
Can someone give me another idea of email domain validation in C#?