Check if an email address is valid – the telnet way

You can use telnet to check if an email is valid. You can actually send emails via telnet, but we’ll stick to checking for now. Remember that this is not a string validation but a complete check with the mail server if the user is valid.

For this example we will use [email protected]. We first need to check the MX record for In Linux is as simple as:

> dig MX

; <<>> DiG 9.6-ESV-R4 <<>> MX
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53492
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 3, ADDITIONAL: 0

;                    IN      MX

;; ANSWER SECTION:             86400   IN      MX      5 ALT2.ASPMX.L.GOOGLE.COM.             86400   IN      MX      10 ASPMX2.GOOGLEMAIL.COM.             86400   IN      MX      10 ASPMX3.GOOGLEMAIL.COM.             86400   IN      MX      10 ASPMX4.GOOGLEMAIL.COM.             86400   IN      MX      10 ASPMX5.GOOGLEMAIL.COM.             86400   IN      MX      1 ASPMX.L.GOOGLE.COM.             86400   IN      MX      5 ALT1.ASPMX.L.GOOGLE.COM.

;; AUTHORITY SECTION:             86400   IN      NS             86400   IN      NS             86400   IN      NS

;; Query time: 0 msec
;; WHEN: Sat Jul  2 21:48:05 2011
;; MSG SIZE  rcvd: 261

On Windows platforms there is no integrated dig utility. You can use this app, or you can use a free online check like this one:

MX checking with
MX checking with

Either way you will end up with the MX server or servers for the domain. Notice there is a number in front of the MX servers in the list, that indicates priority (smaller means higher priority). We will use the highest priority server available and if this one fails we can try the next one.

It’s time to connect to the server (from the command line in Linux or Windows):

> telnet ASPMX.L.GOOGLE.COM 25
Connected to ASPMX.L.GOOGLE.COM.
Escape character is '^]'.
220 ESMTP y26si6167249fag.156
250 at your service
mail from: <[email protected]>
250 2.1.0 OK y26si6167249fag.156
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 y26si6167249fag.156
rcpt to: <[email protected]>
250 2.1.5 OK y26si6167249fag.156
221 2.0.0 closing connection y26si6167249fag.156
Connection closed by foreign host.

The bolded lines are the ones you type, the others are responses from the server.

All servers should abide to RFC 821. Most do, a few don’t. I noticed some servers are accepting all addresses as valid. This is not a standard response but you can check if this occures testing an email like [email protected].

The response code you are interested in is 250. This means it’s a valid address. 550 means that the user does not exist. There are other codes as well and you can do further reading in the RFC.

Please note that helo command must be run before anything else. and [email protected] can be changed in anything you please.

To close the connection after validation just type quit.



, ,