Telnet to POP3 or SMTP for Testing

General

Email is a tricky thing to do right, though a couple of simple tools can help you test your mail server before you start to use it, i.e. make sure mail can be delivered correctly to a users mailbox. Also it can help diagnosing certain problems that you might have with your email.

POP – Post Office Protocol is for recieving mail, this is the slightly simpler service to use.

SMTP – Simple Mail Transfer Protocol, this is used for delivery of mail between mail servers. There are certain rules that are useful when diagnosing problems with SMTP servers, check out www.dnsstuff.com and also www.dnsreport.com for more details.

For more information regarding how to use telnet to POP3 or SMTP see the sections below:

Telnet to POP3

It is possible, with many ISPs, to use a Telnet program to do maintenance on your mailbox on the POP3 mail server. This allows you to look at, and possibly delete, any problem causing message (e.g. too large to download, improperly formatted message, etc.) 

You’ll be surprised how often this can happen especially if targeted by hackers who use “mail bombs” to fill up your inbox.

First load up a telnet client, such as the one included in windows. In Win ’95, ’98, click “Start” then “Run” then enter:

telnet name.of.host portnumber

telnet = The name of the program.

name.of.host = The address of your mail server. (e.g. mail.fastisp.com)

portnumber = The port used for mail, normally 110.

You may want to enable “local echo” so you can see what you are typing (quite handy!)

Now Connect…..

1. Enter the above command substituting the correct server address and port number.

2. You should now see this: “+OK InterMail POP3 server ready.”

3. Type: “user yourusername” Where yourusername is your user name.

4. Assuming that is accepted type : “pass yourpassword” where yourpassword is your password.

5. You should then see: ” +OK yourusername is welcome here” or something like it.

6. Now you can use the commands to edit your mail box see the list below:

USER userid

This must be the first command after the connect. Supply your e-mail userid (not the full e-mail address). Example: USER john.smith

PASS password

This must be the next command after USER. Supply your e-mail password. The password may be case sensitive.

The following commands may be used as needed:

STAT

The response to this is: +OK #msgs #bytes Where #msgs is the number of messages in the mail box and #bytes is the total bytes used by all messages. Sample response: +OK 3 345910

LIST

The response to this lists a line for each message with its number and size in bytes, ending with a period on a line by itself. Sample response:

+OK 3 messages

1 1205

2 305

3 344400

.

RETR msg#

This sends message number msg# to you (displays on the Telnet screen). You probably don’t want to do this in Telnet (unless you have turned on Telnet logging). Example: RETR 2

TOP msg# #lines

This is an optional POP3 command. Not all POP3 servers support it. It lists the header for msg# and the first #lines of the message text. For example, TOP 1 0 would list just the headers for message 1, where as TOP 1 5 would list the headers and first 5 lines of the message text.

DELE msg#

This marks message number msg# for deletion from the server. This is the way to get rid a problem causing message. It is not actually deleted until the QUIT command is issued. If you lose the connection to the mail server before issuing the QUIT command, the server should not delete any messages. Example: DELE 3

RSET

This resets (unmarks) any messages previously marked for deletion in this session so that the QUIT command will not delete them.

QUIT

This deletes any messages marked for deletion, and then logs you off of the mail server. This is the last command to use. This does not disconnect you from the ISP, just the mailbox.

Telnet to SMTP

Telneting to SMTP is quite straight forward, though for this example will use the following email addreses etc:

Sender Address: bert@sendthatmail.com

Reciever Address: jimmy@givememail.com

Reciever Mail Server: mail.givememail.com

Connecting to SMTP Port

Telnet to port 25 using the following command: telnet mail.givememail.com 25

If you are connected you should see something like:

Trying A.B.C.D...
Connected to mail.givememail.com.
Escape character is '^]'.
220 mail.givememail.com ESMTP Exim 4.04 Wed, 13 Nov 2002 16:27:42 -0700

Now you need to use the HELO command followed by the senders domain i.e. sendthatmail.com: helo sendthatmail.com

Now you have done that you should see:

250 mail.givememail.com Hello sendthatmail.com [E.F.G.H]

Now you need to enter the “MAIL FROM:” command followed by the sender’s whole email address: mail from: bert@sendthatmail.com

You will then see:

250 OK

Now put in the reciever address using the command: rcpt to: jimmy@givememail.com

You will then see:

250 Accepted

Now you need to type in the mail message use the “DATA” command as shown below:

data

354 Enter message, ending with “.” on a line by itself

Subject:Test Message

This is a test message.

.

Once completed you should see this:

250 OK id=18C6vd-0005Ey-00

Now when you are done, type in “QUIT” to end the session.

Below is a quick summary that I found from the Internet regarding this, quite handy just for quick reference:

root@Linux:/> telnet mailhub.somedomain.com 25
Trying A.B.C.D...
Connected to mailhub.somedomain.com.
Escape character is '^]'.
220 mailhub.somedomain.com ESMTP Exim 4.04 Wed, 13 Nov 2002 16:27:42 -0700
helo someotherdomain.com
250 mailhub.somedomain.com Hello someotherdomain.com [E.F.G.H]
mail from: Jim@someotherdomain.com
250 OK
rcpt to: Joe@somedomain.com
250 Accepted
data
354 Enter message, ending with "." on a line by itself
Subject:Test Message
This is a test message.
.
250 OK id=18C6vd-0005Ey-00
quit

Leave a Reply

Your email address will not be published. Required fields are marked *