Telnet 25 - checking email connections

As I use this frequently to test remote mail hosts for one of my clients, I figure it deserves a spot here. This will allow you to manually test a remote mail server using telnet and port 25:

First get the mail server address for a website. We will use gmail.com for our example:

dig gmail.com mx
...
    gmail.com.  1654  IN  MX  50 gsmtp183.google.com.
    gmail.com.  1654  IN  MX  5 gmail-smtp-in.l.google.com.
    gmail.com.  1654  IN  MX  10 alt1.gmail-smtp-in.l.google.com.
    gmail.com.  1654  IN  MX  10 alt2.gmail-smtp-in.l.google.com.
    gmail.com.  1654  IN  MX  50 gsmtp147.google.com.
... 

Not sure if there is a specific mail server to choose, but I usually choose one with a higher priority. In this case I will choose gmail-smtp-in.l.google.com to test from my server:

telnet alt2.gmail-smtp-in.l.google.com 25
    Trying 66.249.91.27...
    Connected to alt2.gmail-smtp-in.l.google.com (66.249.91.27).
    Escape character is '^]'.
    220 mx.google.com ESMTP y37si31029380iky.4
    HELO outofcontrol.ca
    250 mx.google.com at your service
    MAIL FROM:<myemailaddress@outofcontrol.ca>
    250 2.1.0 OK y37si31029380iky.4
    RCPT TO:<mygmailaddress@gmail.com>
    250 2.1.5 OK y37si31029380iky.4
    DATA
    354  Go ahead y37si31029380iky.4
    This is a test.
    .
    250 2.0.0 OK 1230083982 y37si31029380iky.4
    QUIT
    221 2.0.0 closing connection y37si31029380iky.4
    Connection closed by foreign host.

A few notes:
On most email servers you do NOT need to include the < or > tags around the email address. Stricter mail servers require it. On gmail if you do not include them you get a nasty '555 5.5.2 Syntax error'.
Don't do anything nasty or stupid, as you can be easily traced through the remote servers mail log. This how-to is to help remind me and to help you trouble shot potential email issues with remote servers, or even to your own server.

Enjoy.

Comments