X

How to check if an email address really exists

In this article, you’ll learn how to use the command line to verify whether a specific email address exists or not, without sending an email. You don’t have to pay for any software or online services and you don’t have to send out test emails. You can do it all for free through the command line, without any limits on how many times you can do it!

When you send an email to user@domain.com, the sending mail server will look up the MX record in DNS for ‘domain.com’ and if one or more MX records are found, the sending mail server will try to deliver the email to the mail server specified in the domain.com MX record.

 

Let’s try to verify if the address someuser@gmail.com exists or not. First, we need to find the MX records associated with the recipient’s domain, in our case that is gmail.com. We will use a DNS lookup utility called dig which is installed on most Linux systems. At the command prompt, type:

$ dig gmail.com MX

The output should look something like this:

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6 <<>> gmail.com MX @8.8.8.8
;; global options: +cmd
;; Got answer:
;; - > >HEADER< < - opcode: QUERY, status: NOERROR, id: 32294
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;gmail.com.                     IN      MX

;; ANSWER SECTION:
gmail.com.              3599    IN      MX      10 alt1.gmail-smtp-in.l.google.com.
gmail.com.              3599    IN      MX      20 alt2.gmail-smtp-in.l.google.com.
gmail.com.              3599    IN      MX      30 alt3.gmail-smtp-in.l.google.com.
gmail.com.              3599    IN      MX      40 alt4.gmail-smtp-in.l.google.com.
gmail.com.              3599    IN      MX      5 gmail-smtp-in.l.google.com.

;; Query time: 20 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Aug 26 10:13:19 2016
;; MSG SIZE  rcvd: 150
;

We can notice that there are multiple MX records each with a different preference level value. The smaller the value, the higher the priority. The sending server will first try to deliver the email to the server with the highest priority and in our case that is ‘gmail-smtp-in.l.google.com’

Next, we need to connect to the ‘gmail-smtp-in.l.google.com’ mail server on port 25 (SMTP) to confirm the validity of the someuser@gmail.com email address. For this, we can use either telnet or netcat. Both tools are available from the software repositories of most Linux distributions.

$ nc gmail-smtp-in.l.google.com 25 # or telent gmail-smtp-in.l.google.com 25
220 mx.google.com ESMTP a12si21630825itb.5 - gsmtp

To start the conversation type HELO. Some servers also accept EHLO in place of HELO.

HELO mydomain.com
250 mx.google.com at your service

Type: mail from:<name@mydomain.com>

mail from:<name@mydomain.com>
250 2.1.0 OK v72si21823782itb.85 - gsmtp

If the server responds with “250”, it means that we can proceed further. Next, type: rcpt to:<someuser@gmail.com>

rcpt to:<someuser@gmail.com>
250 2.1.5 OK v72si21823782itb.85 - gsmtp

The server response will show us whether the email address “someuser@gmail.com” is valid or not.
If you get “250 OK” it means that the email address exists.

If you get a response of “550” as shown below, it means that email account that you tried to reach does not exist.

rcpt to:<someuser2345@gmail.com>
550-5.1.1 The email account that you tried to reach does not exist. Please try
550-5.1.1 double-checking the recipient's email address for typos or
550-5.1.1 unnecessary spaces. Learn more at
550 5.1.1  https://support.google.com/mail/answer/6596 y18si12470464ioi.55 - gsmtp

That’s it! We hope you found this as useful as we did.

Please note that if you do this repeatedly from the same IP it may lead to a banned IP. Use with caution.

If you have any questions feel free to comment below or sign up for our hosting services and contact our EPIC Support Team. They are available 24/7 and they will take care of your request immediately.


PS. If you liked this post please share it with your friends on the social networks using the sharing buttons or simply leave a reply below. Thanks.

View Comments

  • why not use the SMTP command that was designed for this purpose? the command is VRFY => "Verifies that a mailbox is available for message delivery; for example, vrfy ted verifies that a mailbox for Ted resides on the local server. This command is off by default in Exchange implementations."

  • Good advice! I've used telnet to send test emails with the same method but I've never thought that I can also see the existence of the recipient in the process.