Click here to Skip to main content
15,122,218 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 ("")
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

TcpClient tClient = new TcpClient("", 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:<>" + 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;

dataBuffer = BytesFromString("QUITE" + CRLF);
netStream.Write(dataBuffer, 0, dataBuffer.Length);
Updated 16-Sep-12 20:15pm

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[^]
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.


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

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