I am designing one web page which checks the existence of the Email Address on the server
For that I have the following code.....this code checks the the existence of gmail address for
e.g [email protected] on the Gmail server
so can anyone please tell me what is the MX Record Entry of Hotmail,Yahoomail and Rediffmail provider.
Code
TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 25);Code
string CRLF = "\r\n";Code
byte[] dataBuffer;Code
string ResponseString;Code
NetworkStream netStream = tClient.GetStream();Code
StreamReader reader = new StreamReader(netStream);Code
ResponseString = reader.ReadLine();Code
/* Perform HELO to SMTP Server and get Response */Code
dataBuffer = BytesFromString("HELO KirtanHere" + CRLF);Code
netStream.Write(dataBuffer, 0, dataBuffer.Length);Code
ResponseString = reader.ReadLine();Code
dataBuffer = BytesFromString("MAIL FROM:<[email protected]>" + CRLF);Code
netStream.Write(dataBuffer, 0, dataBuffer.Length);Code
ResponseString = reader.ReadLine();Code
/* Read Response of the RCPT TO Message to know from google if it exist or not */Code
dataBuffer = BytesFromString("RCPT TO:<"+TextBox1.Text.Trim()+">"+CRLF);Code
netStream.Write(dataBuffer, 0, dataBuffer.Length);Code
ResponseString = reader.ReadLine(); if (GetResponseCode(ResponseString) == 550) { Label1.Visible = true; Label1.Text = "Mai Address Does not Exist !";Code
Label1.Text = "<font color='red'>Original Error from Smtp Server :</font>" + ResponseString;Code
//Response.Write("Mai Address Does not Exist !<br/><br/>");Code
//Response.Write("<B><font color='red'>Original Error from Smtp Server :</font></b>" + ResponseString);Code
}Code
else { Label1.Visible = true;Code
Label1.Text = "exist";Code
//Response.Write("valid address");Code
} /* QUITE CONNECTION */Code
dataBuffer = BytesFromString("QUITE" + CRLF);Code
netStream.Write(dataBuffer, 0, dataBuffer.Length);Code
tClient.Close();Code
} private byte[] BytesFromString(string str)Code
{ return Encoding.ASCII.GetBytes(str); } private int GetResponseCode(string ResponseString)Code
{ return int.Parse(ResponseString.Substring(0, 3)); }
Answers
Know the answer? Post it. Somebody with the same question will find it here.