Sometimes you need to know whether an email address is real before you send anything important to it. The usual quick test is to send an email and wait to see if it bounces back, but that is not always reliable.
A lot of domains, especially larger ones, may accept mail for addresses that do not really exist and route it somewhere else. That means no bounce message does not always mean the address is valid.
Quick Answer
The practical way to check an email address from Terminal is to look up the domain's MX records, connect to one of its mail servers on port 25, start an SMTP handshake, and use the RCPT TO command to ask whether the server will accept mail for that address.
This does not guarantee a perfect answer on every mail system, because some servers intentionally accept everything or hide address validation. But it is a useful test, and it uses tools already available on many machines.
Why Not Just Send a Test Email?
Sending a test email sounds simple, but it can give you a false sense of certainty. If the message bounces, then yes, that is a strong sign something is wrong.
The problem is when it does not bounce. Some companies use catch-all forwarding or collection mailboxes so that mail sent to nonexistent addresses still lands somewhere. In that case, you may never get a bounce even though the person or inbox you were trying to reach does not exist.
There are also plenty of email verification services online, especially for bulk list checking. Some may be useful, but for a one-off check, I like knowing how to do it myself from Terminal.
Step 1: Find the Mail Server
The first thing you need is the MX record for the domain part of the email address. If the address is johnsmith@gmail.com, the domain is gmail.com.
On macOS Terminal, you can use nslookup to ask for the MX records:
- nslookup -type=MX gmail.com
- Look for the mail server names returned in the result.
- Large domains usually return several MX servers.
- When there are multiple options, choosing one with the lowest priority number is usually a reasonable place to start.
Step 2: Connect Over SMTP
Once you have one of the mail server hostnames, connect to it using telnet on port 25. Port 25 is the traditional SMTP port used for mail server communication.
The command looks like this, replacing the server name with one of the MX records you found:
- telnet mail-server.example.com 25
Step 3: Start the Handshake
After connecting, start the SMTP conversation with the HELO command. It is spelled with one L:
- HELO
Step 4: Provide a Sender
Next, the mail server expects a sender address. For this test, the sender does not need to be a real inbox. You are not actually trying to send a message here; you are only getting far enough into the SMTP conversation to ask whether the recipient is accepted.
- MAIL FROM:<test@test.com>
Step 5: Check the Recipient
Now use the RCPT TO command with the address you want to verify:
- RCPT TO:<johnsmith@gmail.com>
How to Read the Result
At this point, the server will respond. If it accepts the recipient, you may see an OK-style response. If the address is not accepted, the server may return an error or a custom message.
The exact wording depends on the mail server. Some servers are more direct than others. Some may reject invalid recipients right away, while others may accept the request even if the mailbox is not real.
Once you are connected, you can try additional RCPT TO commands to check other addresses on that same domain without starting over.
Important Limitation
This is a verification technique, not a guarantee. Some mail systems are designed specifically to avoid revealing whether a mailbox exists. Others use catch-all behavior, spam filtering, or garbage collection mailboxes that make invalid addresses look valid from the outside.
So I would treat this as a useful signal, especially when a server clearly rejects the address, but not as courtroom-level proof that a person actively uses that inbox.
Key Takeaways
- You can check many email addresses from Terminal without sending a test email.
- Start by looking up the domain's MX records with nslookup.
- Connect to a mail server using telnet on port 25.
- Use HELO, MAIL FROM, and RCPT TO to ask whether the server accepts the address.
- A rejection is useful information, but an accepted response is not always a guarantee because some domains use catch-all forwarding or filtering.
Watch the Video
The video above above if you want to see the Terminal commands run step by step and how the SMTP responses look in practice.