i am creating a web service to validate if an email inputted by a user exists or not. here is the web method.The problem is the method always returns true when the email is wrong or right.
[WebMethod(Description = "This method is used to validate email")]
public bool ValidateEmail(string email)
{
bool isValid = false;
try
{
string[] host = (email.Split('@'));
string hostname = host[1];
IPHostEntry IPhost = Dns.GetHostByName(hostname);
IPEndPoint endPt = new IPEndPoint(IPhost.AddressList[0], 25);
Socket soc = new Socket(endPt.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
soc.Connect(endPt); //open connection to host
soc.Close();
isValid = true;
}
catch (Exception ex)
{
//ex.Message.ToString();
isValid = false;
}
return isValid = true;
}