Sir, i want to do an email validation i.e. i want to check whether and email ID exist or not. I want to check for all the domain such as yahoo, gmail, rediffmail, hotmail, etc. Please send me the solution with the code.
I tried with the following code, but it only works for email.
using System.Net.Sockets;
using System.IO;
using System.Text;public partial class _Default : System.Web.UI.Page
{
protected void btnCheck_Click(object sender, EventArgs e)
{
TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25);
string CRLF = "\r\n";
byte[] dataBuffer;
string ResponseString;
NetworkStream netStream = tClient.GetStream();
StreamReader reader = new StreamReader(netStream);
ResponseString = reader.ReadLine();
/* Perform HELO to SMTP Server and get Response */
dataBuffer = BytesFromString("HELO KirtanHere" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
dataBuffer = BytesFromString("MAIL FROM:<[email protected]>" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
/* Read Response of the RCPT TO Message to know from google if it exist or not */
dataBuffer = BytesFromString("RCPT TO:<"+TextBox1.Text.Trim()+">"+CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
if (GetResponseCode(ResponseString) == 550)
{
Response.Write("Mai Address Does not Exist !
");
Response.Write("Original Error from Smtp Server :"+ResponseString);
}
/* QUITE CONNECTION */
dataBuffer = BytesFromString("QUITE" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
tClient.Close();
}
private byte[] BytesFromString(string str)
{
return Encoding.ASCII.GetBytes(str);
}
private int GetResponseCode(string ResponseString)
{
return int.Parse(ResponseString.Substring(0, 3));
}
Loading
Joy FernandesPosted Feb 24, 2015, 4:08 AM
Jignesh TrivediPosted Feb 19, 2015, 11:43 PM
Hi,
Please refer below article it might help you.
http://www.c-sharpcorner.com/UploadFile/kirtan007/check-if-email-address-really-exist-or-not-using-C-Sharp/
http://stackoverflow.com/questions/3883518/can-i-check-if-an-email-address-exists-using-net
Khargesh RajputPosted Feb 19, 2015, 11:28 PM
above link has demo and download source code from here
but i think you have to purchase library from aspnetmx from here