Simple steps to verify email id existence

Email id exists or notOur team always face email existence problem when they try to:

  • Verify the  registered account holder’s email id or
  • While sending mail to anonymous user who posted comment with some fake email id or
  • To check, if that email address is still valid (ex: 2 years back emailed was valid but not now)

Well it’s not possible to know 100% whether given e-mail address exists in real or not but it will be handy in majority of the cases. You can do it manually also if you are in Linux box using host or nslookup and telnet command. I would prefer host command for this purpose.

How it works:

  • Check if domain name exists or not using ping command
  • If domain name exists then check if it has any mail handlers i.e. mx records in DNS. Use host or nslookup command for it
  • If mx record exists for that domain name use that mail handler using telnet command
  • Use telnet and smtp command to verify user email id. If you get 250/Ok for user email id. You may assume that it exists.

Here many things came into the picture while testing various mail ids from various mail handlers. I will discuss it under “possible ways of failures”

Steps to check the email existence manually

1.       Get the mail id to verify (we can get domain-name from this format to use it in our next step userid@domain-name . For

2.       Either use nslookup command or host command to get mail server address (Lists of mx records from DNS)

a.       Using nslookup:
nslookup –type=mx domain-name

b.      Using host :
host –t mx domain-name

3.       Get the least digital value’s mx record to use it in telnet

a.       telnet mxrecord port-no i.e. telnet 25

b.      Once connected use SMTP commands to know if email id exists or not. It will return 250 as a return code with OK or Accepted. Depending upon mail server configuration and Linux flavors too.

Let’s see it practically with all combination of commands, inputs and outputs 😀

Output from nslookup (it will show many more things which I have not shown here)

$ nslookup -type=mx
Non-authoritative answer:       mail exchanger = 20       mail exchanger = 30       mail exchanger = 40       mail exchanger = 5       mail exchanger = 10

Output from host command ( I prefer this over nslookup )

$ host -t mx mail is handled by 30 mail is handled by 40 mail is handled by 5 mail is handled by 10 mail is handled by 20

Get the value which has lowest ranked digit. In this case it is 5 so take for our purpose
Either use host or nslookup for the first stage.

Telnet outputs:

Step 1

telnet 25
Connected to
Escape character is ‘^]’.
220 ESMTP hk4si16050652obc.168

Step 2 (type helo, if it didn’t work try helo hi, if it didn’t work too try ehlo then )

250 at your service

Step 3 (type any valid email id. Invalid email id will say ok but after rcpt to it will throw an error and don’t skip this step)

mail from: <>
250 2.1.0 OK hk4si16050652obc.168

Step 4 (You need to provide email which needs to be verified.  Ok means it may exists. Not 1005 guaranteed on existence but we can infer that this email id may work)

rcpt to: <>
250 2.1.5 OK hk4si16050652obc.168

Telnet outputs on failure (Various reasons are there)

1.       Network is unreachable. (sometimes it is reachable form one host but not from others)

telnet 25

telnet: connect to address Connection timed out
Trying 2001:4860:8005::1b…

telnet: connect to address 2001:4860:8005::1b: Network is unreachable

telnet: Unable to connect to remote host: Network is unreachable

2.       Error at mail from:<mail-id> :

  • Don’t forget to use <> while typing email id. is wrong. is correct
  • Never use space before or  after mail id
  • Don’t use single quote or double quote while typing email id

3.       If email id exists but it doesn’t show up 250/ok then below reasons may justify this:

  • Server response delayed
  • Email address black listed
  • Email does not exist  (even if it existed 2 years back )

Steps to check email existence using Perl

  1. Get Mail::CheckUser module from CPAN
  2. Install it either manually or using cpan command
  3. Write simple script using this module and check the output

Good thing with this script is:

  • You don’t need to use any command like host, nslookup telnet and don’t need to remember all those SMTP commands.
  • Just pass the email id rest thing it will do.
  • Internally it checks:
  • It checks the syntax of an email address.
  • It checks if there any MX records or A records for the domain part of the email address.
  • It tries to connect to an email server directly via SMTP to check if mailbox is valid. It can detect bad mailboxes in many cases.

Here is the fully working Perl script

Why still this trick doesn’t assure 100% proof that email id exists or not?

There can be many reasons for not trusting on this script or the above said manual steps. Best way is to send an email to the given email id. If it bounced back, means it doesn’t exist or can’t be delivered. (I chat with a person in gtalk but can’t send an email to that person. Strange isn’t it).

  • There may be server delay
  • Email id may be black listed
  • It may say it exists if it has to bypass proxies
  • Final output will depend upon server settings which may be using  an algorithm to stop spammer like stuffs
  • For instance SMTP defines the VRFY command for this purpose but gmail doesn’t support it.
  • Never send bulk emails, your mail id will be flagged as a spammers by many hosting companies
  • You may not get proper result because network is unreachable or down by that time

Note: This was just for educational purpose and found helpful for web masters or admins. Don’t use it as spam stuffs, you IP address and your mail id will be blacklisted. Like has been blacklisted from various mail servers.

Sanjeev Jaiswal

He loves web programming and security and co-founder of Alien Coders. He usually shares and helps engineering students and IT professionals in academics and jobs. An avid reader and quick learner.

Share your comment

%d bloggers like this: