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:
firstname.lastname@example.org [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.
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 email@example.com really exists go through the following in command prompt.
First - Find mail exchanger of reddit.com
nslookup – q=mx reddit.com
reddit.com MX preference = 10, mail exchanger = mail.reddit.com
mail.reddit.com internet address = 188.8.131.52
Second - Connect to mail server mail.reddit.com
telnet mail.reddit.com 25
220 mail.reddit.com 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 http://www.reddit.com/static/inbound-email-policy.html for more information.
mail from: <firstname.lastname@example.org>
250 2.1.0 Ok
rcpt to: <email@example.com>
550 5.1.1 <firstname.lastname@example.org>: 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.
Telnet screenshot in windows – Check email using SMTP commands
UPDATE: PHP code added on 26th January 08