Validation of A Valid Email Domain
-
Hey guys need ur help again. I need to check the valid email address using asp.net Below are the code i use hostName = "yahoo.com"; private bool ValidSMTP(string hostName) { bool valid = false; try { TcpClient smtpTest = new TcpClient(); smtpTest.Connect(hostName, 25); if (smtpTest.Connected) { NetworkStream ns = smtpTest.GetStream(); StreamReader sr = new StreamReader(ns); if (sr.ReadLine().Contains("220")) { valid = true; } smtpTest.Close(); } } catch (Exception e) { string a = e.Message; } return valid; } However the error msg i receive is this "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." Any solution or other methods of validating a exist email address? Thanks
KaKaShi HaTaKe
-
Hey guys need ur help again. I need to check the valid email address using asp.net Below are the code i use hostName = "yahoo.com"; private bool ValidSMTP(string hostName) { bool valid = false; try { TcpClient smtpTest = new TcpClient(); smtpTest.Connect(hostName, 25); if (smtpTest.Connected) { NetworkStream ns = smtpTest.GetStream(); StreamReader sr = new StreamReader(ns); if (sr.ReadLine().Contains("220")) { valid = true; } smtpTest.Close(); } } catch (Exception e) { string a = e.Message; } return valid; } However the error msg i receive is this "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." Any solution or other methods of validating a exist email address? Thanks
KaKaShi HaTaKe
There is no way to check if a mail address is valid, apart from mailing it and seeing if you get a bounceback message. Even that is not 100% accurate.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.