How to use telnet for diagnostics

From QmailToaster wiki
Jump to navigation Jump to search

How to use telnet to troubleshoot problems[edit]

Telnet is a very versatile tool, and can be used to test various things with a mail server. To send a message to an existing user on your server to test mail flow:

telnet 25
HELO desktop
Subject: Testing
Whatever else you want to say.

What this does, line by line, is:

1. Open a telnet session to your server on port 25 (best used when telnet'ing from an outside network)
2. Telling the server your local name you're sending mail from (this is usually your computer's network name, with optional domain name appended). You should receive a 250 code back.
3. Who the mail is from (RBL check will apply, and you can test DNS timing as well - how long does it take to get a 250 - ok reply back?  This will tell you how long your server is spending doing reverse DNS lookups/RBL lookups.
4. This is who the message is to.  You should receive a 250 ok message back if the user exists, or an error if the user does not exist.
5. You're letting the server know that the message data is going to be next.
6. This will be the subject of the message.  While technically not required, it does make it easier to find the message if you get a lot of them.
7. The actual message body.  Type whatever you want.
8. The period (.) on it's own line, all by itself, tells the server that you are DONE sending the data to it and to deliver the message.
9. You need to let the remote server know you want to quit, or it will wait for the next SMTP command (mailers would normally check mail here, or send another message)

A key thing to note is that you cannot use the backspace/delete key during the telnet session (at least not on the command portions). You will receive an error if you try and delete backwards because you misspelled RCPT TO: or the email address.