Prasanna Pachi

Prasanna Pachi

  • NA
  • 35
  • 817

email existance check code it showing error?

Mar 28 2015 6:30 AM
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 Congnition Infosystem Here" + 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:<" + email_id.Text.Trim() + ">" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();
if (GetResponseCode(ResponseString) == 550)
{
l3.Text = "Mail Address <B><font color='red'> " + email_id.Text + "</font></b> Does not Exist !<br/><br/>";
l4.Text = "<B><font color='red'>Original Error from Smtp Server :</font></b>" + ResponseString;
}
///* QUITE CONNECTION */
else if (GetResponseCode(ResponseString) == 250)
{
l3.Text = "<B><font color='green'>Email-id Exist</font></b><br>";
l4.Text = "<B><font color='green'>MX record Found </font></b>" + ResponseString;
}
else
{
dataBuffer = BytesFromString("QUITE" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
tClient.Close();
l3.Text = "<B><font color='green'>Email-id Exist</font></b><br>";
l4.Text = "<B><font color='green'>MX record Found </font></b>" + ResponseString;
//ScriptManager.RegisterStartupScript(Page,typeof(string),"alert","alert('Email-Id existed')",true);
}
}
 
 
"in first line Tcpclient it showing error like 'The requested address is not valid in its context 74.125.130.27:25'     Please solve how to solve this error?" 

Answers (1)