Note: The code written here by me is for checking if a particular Gmail address exists or not. To make this code work with other Mail Providers you need to find the Mail Server of the particular email provider by Querying
MX Record Entry of the particular mail provider.
Here is how you can determine MX Record of a particular mail server using cmd
Here I used the basic technique of SMTP commands to check if mail addresses exist or not.
Here is how typical mail server communication is done.
Receiver: 220 server.com
Simple Mail Transfer Service Ready
Sender: HELO server.com
Receiver: 250 server.com
Receiver: 250 OK
Receiver: 250 OK
Here when we perform RCPT TO command server checks the existence of a particular mail address by querying the server and if it finds that the Mail Address is correct it responds with a 550 code and error message.
So we will fire RCPT TO command against the Gmail server and the Gmail server will respond with an error message if the email address in the recipient field is not correct. if we get error that means the email address is not the correct one and we can display an error to the user.
Now let's do the actual code work in which we will perform communication to the SMTP server exactly as shown
- Connect to server
- Perform HELO
- Fire MAIL FROM command
- Fire RCPT TO command and check Response
Now to perform all this we need to communicate with the server using Sockets I selected TcpClient to perform code. code like below to perform communication with server.
madhu mithaPosted May 17, 2021, 12:17 PM
The code is not working for me." A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. 74.125.200.26:25 " shows this error
kokila selvamaniPosted Jun 4, 2018, 7:06 AM
Hello i can only check for gmail account not able to check for outlook ,live accounts pls help to solve this
Vicky SktPosted Sep 21, 2017, 7:01 AM
I use your code for yahoo and outlook domain. But this gives me an exception on connection after the hello message the exception is the following "550 5.7.1 Service unavailable, Client host [103.255.5.117] blocked using Spamhaus. To request removal from this list see http://www.spamhaus.org/lookup.lasso (AS3130)."Please help me what should i do. I try www.spamhaus.org/lookup.lasso but i nothing understand what should i do for this.
Akshay PorwalPosted Sep 19, 2017, 9:51 AM
Hello, very nice article, i am facing one issue that , whatever the email id i give in dataBuffer = BytesFromString("RCPT TO:<" + txtDLApprovalSendTo.Text.Trim() + ">" + CRLF); its always coming "250"(i.e correct),.. Please help me to solve this issue . why it is always coming correct instead to goving wrong address. or you can email me on [email protected] in advance]
mehrtash souriPosted Feb 5, 2017, 9:15 AM
TcpClient tClient = new TcpClient("gmail-smtp-in.l.google.com", 587);
mehrtash souriPosted Feb 5, 2017, 9:14 AM
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.68.27:587
Manav PandyaPosted Oct 4, 2016, 1:06 PM
Great ...
Munesh SharmaPosted Jul 13, 2016, 3:23 AM
Nice
prashanth SuthojuPosted Mar 22, 2016, 6:33 AM
it only working for gmail i need others also can anyone help me..
Sudheer GPosted Mar 15, 2016, 2:57 AM
If am enter yahoo, hotmail it's not working. Other email ids how to write code???
dharmendar singhPosted Sep 28, 2015, 1:41 AM
Can u please provide to check all type of domain like yahoo,redif etc
manikandan cPosted Aug 27, 2015, 5:50 AM
can u please provide to check all type of domain like yahoo,redif etc
SandyPosted Apr 20, 2015, 2:36 AM
you can take any of yahoo mail id.e.g. [email protected]
sankar raoPosted Apr 18, 2015, 7:10 AM
can you please provide for all type of email addresses
sankar raoPosted Apr 17, 2015, 7:42 AM
For gmail accounts it is working fine but how to check other mails like yahoo, rediff etc...... can you please help for this
Punit SinghPosted Feb 26, 2015, 5:30 AM
thnaks Kirtan Patel Sir.
Riddhi ValechaPosted Dec 25, 2014, 8:07 AM
Hi...Please help me out. I am also stuck in this issue. I have a domain (in.infosys.com). I have to check whether the email ID ([email protected]) really exists or not. Also, I tried this example. But I am getting error - Connection Time out.
Bhaskar SPosted Oct 13, 2014, 8:45 AM
How to make this work for remaining mail servers like yahoo, rediff....etc... i tried as you explained above in command prompt to get the mail server and used it in your code, it is showing error not working.. please help me
SandyPosted Jun 12, 2014, 7:52 AM
It block my 25 port ip
janvi pateleditedPosted Nov 21, 2012, 4:57 AMEdited Nov 22, 2012, 12:38 AM
nice artical
Syed AliPosted Mar 20, 2012, 2:21 AM
its check only domail not user id
Jimmy UnderwoodPosted Dec 24, 2011, 12:01 AM
Thanks Mr. Kirtan
Alok PandeyPosted Dec 23, 2011, 1:51 AM
Nice article, Kirtan. I was searching for such article.
Daisy KrausePosted Dec 23, 2011, 1:49 AM
Nice article. Thanks for sharing it.
Arjun PanwarPosted Dec 23, 2011, 1:41 AM
Thanks for sharing
Dinesh BeniwalPosted Dec 23, 2011, 1:31 AM
Welcome back