How to check if an email address exists without sending an email?

We have all been doing email address validation for a very long time to make sure that the email is correctly formatted. This is to avoid users entering wrongly formatted email address but still they can accidentally give us a wrong email address.

Example of a correctly formatted email address but still wrong: [VALID format but does not exist]

Above case specifically happens when you take important customer email on phone and you type in the wrong email. So is there a QUICK solution to really check the email without sending a test message to the user? Yes.

The solution

A quick & simple check below can be implemented in most programming language including PHP, Python etc. It relies on using the same SMTP which is used to send emails.

To check if user entered email really exists go through the following in command prompt.

First - Find mail exchanger of

nslookup – q=mx
RESPONSE:      MX preference = 10, mail exchanger = internet address =

Second - Connect to mail server

telnet 25
220 ESMTP Postfix NO UCE NO UEMA  C=US L=CA Unsolicated electronic mail advertisements strictly prohibited, subject to fine under CA law CBPC 17538.45.  This electronic mail service provider’s equipment is located in the State of California.  See for more information.

helo hi

mail from: <>
250 2.1.0 Ok

rcpt to: <>
550 5.1.1 <>: Recipient address rejected: User unknown in local recipient table

221 2.0.0 Bye


1) the 550 response indicates that the email address is not valid and you have caught a valid but wrong email address. This code can be on the server and called on AJAX when user tabs out of the email field.  The entire check will take less than 2 seconds to run and you can make sure that the email is correct.
2) If email was present the server will respond with a 250 instead of 550
3) There are certain servers with a CATCH ALL email and this means all email address are accepted as valid on their servers (RARE but some servers do have this setting).
4) Please do not use this method to continuously to check for availability of gmail / yahoo / msn accounts etc as this may cause your IP to be added to a blacklist.
5) This is to supplement the standard email address javascript validation.

Telnet screenshot in windows – Check email using SMTP commands

UPDATE: PHP code added on 26th January 08

1) SMTP check code in PHP – DOWNLOAD

2) Usage example – DOWNLOAD

Also read...


  1. Pingback: alguna funcion php para verificar existencia de un correo? - Foros de CHW

  2. severin said on :

    Thanks for this useful trick. Unfortunately it does not work with the server I tried. It says:
    554 Your access to this mail system has been rejected due to the sending MTA’s p
    oor reputation. If you believe that this failure is in error, please contact the
    intended recipient via alternate means.

    Looks like there’s no workaround?

  3. Amit said on :

    Live demo would be appreciated !

  4. Jasmine said on :

    Wow, these code snippets are really good. I have been looking for a way to check if an email is valid on gmail! This code will be very helpful!

  5. newvalidate said on :

    I get error “Warning: SMTP_validateEmail::require_once(Net_DNS.php) [function.SMTP-validateEmail-require-once]: failed to open stream: No such file or directory in D:\Hosting\4356713\html\smtpvalidateclass.php on line 233

  6. Ousneo said on :

    @newvalidate you have to download NET_DNS class drom PEAR library!!

    I am having my IP reported as spammers !! how to solve this problem ?

  7. I understand your code but this command not executed
    nslookup – q=mx
    nslookup: couldn’t get address for ‘q=mx': not found
    please help me

  8. Secret Guy said on :

    For me I encountered a lot of problem to send a resume through internet because of some error flash of my yahoomail so what can i do for this …

  9. ram said on :

    Hi frnds i did not understood how to check, where to keep the email of users want to check var $user if ikeep like this $user=username of email iwant to check

  10. Lp Bell said on :

    I found the perfect tool:
    gives you 5 free validation for an email with the headers!!!!

  11. Boopathi Raja said on :

    Hi All,

    I have a newsletter option which sends nearly 20,000 emails to my customers. I need to check if the email address is exist and active in real time before sending. Can anyone have the code to check this in PHP ? Please help me to resolve this issue

  12. mohan said on :

    Thanks. simple and clear. I want to know is there any restriction to verify email addresses using this SMTP method.

    I want to verify 1 million email addresses. is it possible??

    Thanks in advance

  13. florin said on :

    You could use this application to check thousands of email account on more email addresses you have:

  14. Thanks for the snippet.

    I’ll try to extend my service for detecting disposable email addresses (see with this kind of testing for the real existence of an email address as a second step. Unfortunately services like yahoo are always answering with “250”, so we have to assume that any email address exists there ..


  15. Searock said on :

    Awesome technique !

  16. Pingback: Email validation script - SitePoint Forums

  17. Stephen Adams said on :

    well i am not for sure that there is a web site and this a phone nu.22998933573 they sent me.I am just trying to find out if this a leget place of bussines or a company.

  18. Very nice guide, presented beautifully and easy to understand.

  19. Clueless said on :

    Sorry for being noobish but is this supposed to work with Windows? nslookup doesn’t understand the first line. There’s an identical question above. This would be a very useful function but the instructions are way, way, way, way, way, over mere mortals heads, assume you know the syntax of everything on any OS and Apollo 11’s LEM computer and mumble RFCs in your sleep. :)

  20. Dont know if there is anything wrong with my email address. If not how is it i cannot locate it and where do i access this. Having roblems cannot subscribe anywhere or receive emails. What am i doing wrong

  21. Bryan said on :

    Is there like a download that can do all that for you

  22. scott said on :

    ok so i took the python code from above and entered into my python idle shell script and got a syntax error??
    nslookup – q=mx

  23. scott said on :

    can i issue these commands thru a macintosh terminal?

  24. Rahul said on :

    Good article. But this assumes that the smtp server runs on port 25 whcih may not be always true. for example, if the mail server uses secure SMTP, the port no will be 465 and we can’t get connection with simple telnet as it is secured.

  25. Pingback: Use PHP To Check Whether Remote URL, Email Or Image Link Exist « DBGLORY 4 YOU

  26. Naidu said on :

    If smtp is running on different port other than default (25), how to check this info? Any way using commands like nslookup?

  27. Omprakash said on :

    This function giving me error while i am exicuting code, the error is

    Warning: Invalid argument supplied for foreach() in C:\wamp\www\Email Validation\smtpvalidateclass.php on line 90

  28. hussain said on :

    my email id has been hacked now password is change how can i recover or delete my email id

  29. Muyeen said on :

    thanks… it was great….

  30. Hi. Just wanted to leave a quick remark and tell you that I’ve enjoyed viewing your personal site and will be recommending it to my mates. Keep up the good work! Thanks again.

  31. Mehdi said on :

    Very useful. Bundle of Thanks.

  32. In the PHP download, there is the following statements:
    // windows, we need Net_DNS
    require_once ‘Net/DNS.php';

    Where can I download that include file?

  33. dilip kumar said on :

    hi ,
    i have a question please give the answer if anybody knows about follwing question .

    i wnat to know how can i check the email address present in gmail and facebook in my website?
    i mean email address present in gmail or facebook, from using that emial address , user can login in my website withought registration..

  34. Abeera said on :

    I just love to add it at thanks for sharing it

  35. This is a very helpful article, and I did have a chance to modify the script to suit my need. The modified script is available at:

    I would like to contribute my change to Google Project, and need your help adding it to the project if you don’t mind.

  36. Bryan said on :

    This doesn’t work with servers that use alternative SMTP ports (465 or 587) and I doubt it works if SSL is required or passwords are required.

  37. Giovanni said on :

    Hi all and thank you for the code. It did really help me out a lot.

    However, I still have a problem on hotmail email address

    I did check it out and enabled SSL on my server, so now it’s working. The problem is that I still get this message back: error 530, could it means authentication required?
    Can you please help me?and give me some avdice?

    I am even thinking of buying it, if someone has a proper working script on PHP o ASP.

    Please write me at

    Thank you

  38. Roland said on :

    Great thanks to this usefull utility.
    I have just a comment. If I call the fonction with the following sequence, it doesn’t work.
    $email = ‘';
    $result = $SMTP_Valid->validate($email, $sender);

    To be usable I have added this line in the function setEmails($emails) :
    settype($emails, “array”);

    Any reaction is welcome.

Comments are closed.