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:

iyngaran@oracle.com[VALID format but does not exist]

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 iyngaran@oracle.com really exists go through the following in command prompt.

First – Find mail exchanger of oracle.com

COMMAND:
nslookup -q=mx oracle.com
RESPONSE:
Server:        192.168.1.1
Address:    192.168.1.1#53

Non-authoritative answer:
oracle.com    mail exchanger = 200 aserp1020.oracle.com.
oracle.com    mail exchanger = 200 aserp1030.oracle.com.
oracle.com    mail exchanger = 200 aserp1060.oracle.com.
oracle.com    mail exchanger = 200 userp1020.oracle.com.
oracle.com    mail exchanger = 200 userp1030.oracle.com.

Authoritative answers can be found from:
oracle.com    nameserver = u-ns3.oracle.com.
oracle.com    nameserver = u-ns2.oracle.com.
oracle.com    nameserver = u-ns4.oracle.com.
oracle.com    nameserver = u-ns6.oracle.com.
oracle.com    nameserver = u-ns1.oracle.com.
oracle.com    nameserver = ns1.oracle.com.
oracle.com    nameserver = ns4.oracle.com.
oracle.com    nameserver = u-ns5.oracle.com.
aserp1020.oracle.com    internet address = 141.146.126.67
aserp1030.oracle.com    internet address = 141.146.126.68
aserp1060.oracle.com    internet address = 141.146.126.71
userp1020.oracle.com    internet address = 156.151.31.79
userp1030.oracle.com    internet address = 156.151.31.80
ns1.oracle.com    internet address = 148.87.1.20
u-ns1.oracle.com    internet address = 204.74.108.1
u-ns2.oracle.com    internet address = 204.74.109.1
u-ns3.oracle.com    internet address = 199.7.68.1
u-ns4.oracle.com    internet address = 199.7.69.1
u-ns5.oracle.com    internet address = 204.74.114.1
u-ns6.oracle.com    internet address = 204.74.115.1

Second – Connect to mail server aserp1030.oracle.com

COMMAND:
telnet aserp1030.oracle.com 25

RESPONSE:
220 aserp1030.oracle.com ESMTP Sendmail Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1; Wed, 30 Oct 2013 02:18:08 GMT

COMMAND:
helo hi
RESPONSE:
250 aserp1030.oracle.com Hello

COMMAND:
mail from: <youremailaddress@yahoo.com>
RESPONSE:
250 2.1.0 <youremailaddress@yahoo.com>… Sender ok

COMMAND:
rcpt to: <iyngaran@oracle.com>

RESPONSE:
503 5.0.0 Need MAIL before RCPT

 

NOTES:

  1. The 503 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 503
  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.

How we can do this using a script ?

We can do this using any programming languages such as PHP, Java, .Net and etc. But here, I am going to do this using PHP.

Here, I have created a class. The class name is – IyngaranMailCheck

This class is meant check the existence of an email address in three levels:

  1. Via regular expression validation
  2. Using domain rules by checking a white list of well known email address provides (ie yahoo.com)
  3. Via SMTP request to simulate a delivery to the address being checked.

On row 41 of IyngaranMailCheck.php substitute the following line

Done. Now we need to test.

 

 

The Response:

The email address iyngaran55@gmail.com exists!
The email address info@yahoo.com doesn’t exists!
The email address invalid#email.com doesn’t exists!
The email address iyngaran@oracle.com doesn’t exists!
The email address info@oracle.com doesn’t exists!
The email address thisdoesentexist@google.com doesn’t exists!

4 Comments

  1. Hi, Neat post. There is an issue together with your site in internet explorer, would check this?
    IE nonetheless is the market chief and a good element
    of folks will leave out your magnificent writing because
    of this problem.

  2. 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.

    How we can over come this point? PLease advise

  3. Hello, I am having issues with implementing the code. The second section where you wrote “On row 41 of IyngaranMailCheck.php substitute the following line” I don’t know how it fits in where exactly because I am getting error notification for replacing Line 41 with that whole code.

    Thanks

Leave a Reply

Your email address will not be published.


*


*