Sometimes you need to know whether an email address is real before you send something important. The usual answer is to send a test email and wait to see if it bounces, but that is not always reliable.
Some domains use catch-all inboxes or garbage collection mailboxes, so a bad address may never bounce back. That can make a fake or mistyped email look valid when it really is not.
Quick Answer
The practical way to check an email address from Terminal is to look up the domain's MX record, connect to one of the mail servers on port 25, start an SMTP handshake, and use the RCPT TO command with the address you want to test.
If the mail server accepts the recipient, the address may be valid. If it rejects the recipient, the address is likely invalid. This is not perfect on every domain, but it gives you more information than simply waiting for a bounce.
Why Not Just Send a Test Email?
Sending a test message is the basic solution, and sometimes it works. If the address does not exist and the mail server sends a bounce, you have your answer.
The problem is that not every system behaves that cleanly. Larger companies and email providers may accept mail for addresses that do not really belong to a user. They may forward those messages into a collection mailbox instead of bouncing them.
That means no bounce does not always mean the address is real. It may only mean the domain accepted the message.
Step 1: Find the MX Record
Start by opening Terminal. On a Mac, the first command I used was nslookup with the MX record type. The MX record tells you which mail servers handle email for that domain.
For example, if you were checking an address at Gmail, you would look up the MX records for gmail.com.
- Command pattern: nslookup -type=mx domain.com
- Example: nslookup -type=mx gmail.com
- Look for one of the mail server hostnames returned by the lookup
Step 2: Connect to the Mail Server
After you have the MX records, choose one of the listed mail servers. Large domains often return several. In the video, I leaned toward the lower priority number and copied that server name.
Then connect to that mail server using telnet on port 25, which is the SMTP port used for this kind of mail server conversation.
- Command pattern: telnet mailserver.example.com 25
- Port 25 is the SMTP port used for this handshake
- If the connection is blocked, your network or ISP may be preventing outbound SMTP connections
Step 3: Start the SMTP Handshake
Once connected, start the handshake with the HELO command. It is spelled H-E-L-O with one L.
After that, identify yourself with a MAIL FROM command. In this test, the sender address does not have to be a real mailbox. The point is to get far enough into the SMTP conversation to ask whether the recipient exists.
- Type: HELO
- Then type: MAIL FROM:<test@test.com>
- The sender address is only used for the SMTP conversation
Step 4: Check the Recipient
Now use the RCPT TO command with the email address you want to verify. This asks the mail server whether it will accept mail for that recipient.
Depending on the server, you may get an OK response, an error message, or some other predefined reply. An OK response suggests the address may be valid. A rejection usually means the address is not accepted by that server.
You can keep testing additional addresses while you are still connected by sending another RCPT TO command.
- Command pattern: RCPT TO:<person@example.com>
- An accepted recipient suggests the address may exist
- A rejected recipient usually means the address is invalid or unavailable
What This Method Can and Cannot Prove
This is a useful check, but it is not a perfect identity test. Some servers are configured to protect user privacy or reduce abuse, so they may not clearly reveal whether a specific mailbox exists.
Other servers may accept everything for a domain, which can still produce a false positive. That is the same general problem you run into when you send a test email and never receive a bounce.
The value of this method is that it is simple, uses tools already available on many machines, and gives you a direct look at how the receiving mail server responds.
Key Takeaways
- You can check many email addresses from Terminal without using a third-party verification service.
- Start by finding the domain's MX records with nslookup -type=mx.
- Connect to one of the mail servers with telnet on port 25.
- Use HELO, MAIL FROM, and RCPT TO to ask the server whether it accepts the recipient.
- An accepted response is useful, but not a guarantee, because some domains use catch-all handling.
- This method can reduce guesswork, but it should not be treated as a perfect verification system.
Watch the Video
The video above above for the full Terminal walkthrough, including the MX lookup, telnet connection, SMTP handshake, and example recipient checks.