Take the 2-minute tour ×

I'm validating email addresses in a c# app, beside the regular expression I'm planning to add some advanced validation by communicating with the mail exchanger and get a response whether such email address exists or not

does any one has a good idea of doing that ? i know a website that can check it :


but I'm not sure what is the approach the website uses for validation. i tried emulating a telnet session on my mail exchanger and then sending commands


but it doesn't work, either the connection is blocked, or the response is erroneous

share|improve this question
Whatever other answers you get, please don't write your own. –  Hbcdev Aug 22 '12 at 16:21
@Hbcdev : you mean, real names, IPs...of course not, but thanks for the reminder –  user1327073 Aug 22 '12 at 16:28
Did you search SO? stackoverflow.com/questions/1365407/… might be useful. –  Hbcdev Aug 22 '12 at 16:31
thanks, but it seems like a real issue...everywhere :), think i'm going to stick with my regex for the moment. –  user1327073 Aug 22 '12 at 18:19
add comment

1 Answer

here's what i did.

1) pass the email through a regex filter.
2) if that passes, check if the domain name is legit using some dns goodies.
3) once the domain is verified, get the first mx record and try to connect (repeat for each mx record until successful connection, and finally abort if none can connect).

an example of the mail commands you'll execute:

telnet mx.server.address.tld 25

helo mydomainname.tld /* many domains reject helo if it doesn't also pass a domain name */
mail from:
rcpt to:

if you get a 220 from the rcpt to command, you're good. if you get a 550 etc then there was a problem. collect the return message and log it for later review.

note, you'll get a response code after each command you send. so use those to track your progress through validation.

some things to consider:
1) running this from a dynamic ip address will often result in not getting results. lots of mail providers block connections from dynamic ip addresses.
2) almost every mail server wants you to wrap the email addresses in < and >.
3) making a large number of connections to the same server is a bad idea. see #4
4) you will get blacklisted faster than you might think if you abuse this approach

there are, of course, other things to consider. frankly i spent a long time researching and creating a tool that has a very high success rate. consider the above a free consultation.

want to see my tool in action? http://www.unlocktheinbox.com/emailvalidator/ if you sign up for a free account you can check out the bulk version too.

good luck


share|improve this answer
your tool works very well, thanks for the response. –  user1327073 Aug 27 '12 at 17:13
add comment

Your Answer


