Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How To check Email ID Exists Or Not

Now I am Checking Any Email Id Exist Or Not

My Main Problem Is That I have No Smtp server name like ("gmail-smtp-in.l.google.com")
Because i Have Multiple Domain Account

If Any Way To Get Smtp Server Name From Email ID
Or Other Way To Check Email ID Account Exits OR Not

Here My Code It Only Check Gmail Account But I Have Many different Email Accounts

C#
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 AnkurHere" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
ResponseString = reader.ReadLine();

dataBuffer = BytesFromString("MAIL FROM:<abc@gmail.com>" + 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)
   {
       label1.Text = "Mai Address Does not Exist !";
       label2.Text = "Original Error from Smtp Server" + ResponseString;
   }

/* QUITE CONNECTION */
dataBuffer = BytesFromString("QUITE" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
tClient.Close();
Posted
Updated 16-Sep-12 19:15pm
v2

Though you cannot check that a specific account exists on a domain, you could at least check that the specified server exists: use e.g. the System.Net.NetworkInformation.Ping class, see http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping%28v=vs.100%29.aspx[^]
 
Share this answer
 
There is no a way to check it it exists or not. If the domain indicated in the domain part exists and the mail delivery agent actually operates on it, it will get your message anyway. What happens next? It depends. Some agents may send your message back and indicate that the addressee is not found, but others will ignore this communication altogether. Even if the "failed to deliver" notification is sent, you usually receive it pretty quickly, but not immediately, so it hardly can be used as you wanted.

For example, a mail system on my site could put all messages with incorrect user names in a special container so I could look it through later, or I could send an auto reply to such messages. As you can see, it is all optional; and different organization use different options, no response being probably most typical.

—SA
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900