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 [email protected], 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 [email protected] 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 @22.214.171.124 ;; 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: 126.96.36.199#53(188.8.131.52) ;; 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 [email protected] 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:<[email protected]>
mail from:<[email protected]> 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:<[email protected]>
rcpt to:<[email protected]> 250 2.1.5 OK v72si21823782itb.85 - gsmtp
The server response will show us whether the email address “[email protected]” 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:<[email protected]> 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.