Tag Archives: telnet

Using Telnet to Send Email

Following up on from my previous post about using telnet to check your email, here’s how you can use telnet to send an email.

There is one very important difference between checking your email and sending an email. Due to the huge amount of spam being sent every day, most ISP’s require that you use their email server to send email. So before you can send an email, you’ll need the name of your ISP’s SMTP server. If you don’t know it, and you’re using either Linux or MacOS X, you can use the nslookup command line utility to find it. Here’s how:

  • Open a command prompt,
  • Type nslookup, and hit enter,
  • Type set querytype=mx, followed by enter,
  • Type the domain name for your isp, i.e., isp.net, hit enter.
  • nslookup will return the mail exchanger address for your isp,
  • Type exit to quit nslookup.

If you don’t have access to nslookup you may be able to guess it from the ISP’s domain name. Taking the ISP domain name to be isp.net:

  • mail.isp.net
  • smtp.isp.net

Now that you have the SMTP server address, you can start sending email. Back to your command prompt and run the following command:

telnet mail.isp.net 25

Once you have connected to the SMTP server, you’ll need to tell it who you are, so type:

helo localhost

You should get a response similar to:

250 mail.isp.net helo localhost [Your IP Address]

Unlike sending email, you don’t need a username and password to login. The next step is to tell the server the email address you’re sending from:

mail from:[Your Email Address]

If the address is accepted by the server you should see:

250 OK

Now tell it the address that you want to email:

rcpt to:[Recipients Email Address]

Once again, if the address is accepted the server will tell you with:

250 Accepted

Now it’s time to start writing your email. You tell the server that you’re ready with this command:


All going well, the server will respond with:

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

Before you can write the actual message content, you need to provide a couple of headers for the email. Not including some basic headers could result in your email being classified as spam, resulting in it being rejected by the recipient. The basic headers to include are Date, From, To, and Subject, as follows:

Date: [Todays Date & Time]From: [Your Email Address]To: [Recipients Email Address]Subject: [Your Email Subject]

Just before starting the content of your email, hit enter to leave a blank line, then start typing!

When you are finished writing your email, hit enter to leave a blank line, type a “.” (no quotes), and hit enter a again. The server should respond with:

250 OK [Message ID]

And that’s it, your message will be queued by the email server and sent on to your recipient.

Using Telnet to Check Your Email

Like a lot of people at this time of year I went home for a few days. It was great to get home for a while, but it has it’s downside – no broadband. So I was transported back to the the dark days of dial-up.

It’s been so long since I used dial-up that I’d forgotten how slow it is. Even checking email can take an age. So here’s a quick guide on how to use telnet to do a quick email check.

Before you start, you’ll need three pieces of information:

  • your mail server address,
  • your user name, and
  • your password.

Once you have these, open a command prompt and type:

telnet mail.server.tld 110

It might take a couple of seconds, but you should get a response from the server. Something along the lines of:

+OK server ready

The next step is to logon to the server with your user credentials:

Enter your user name:

user user name

If the user name has been accepted, the server will respond with:


Now enter your password:

pass password

If you have provided the correct password, then you should get the following server response:

+OK Logged in

To see if you have any messages, you can use either of the following commands:




The list command will return a list of all messages and their respective sizes, while the stat command will return the total number of messages and the total size.

Sample output from the list command:

+OK 2 messages:1 11952 2365.

Sample output from the stat command:

+OK 2 3560

You’ll note from the output of the list command, that each email is numbered. To read your emails, use the retr command:

retr 1

This command will display the entire email message including the headers. If you want to view just part of the message, then use the top command.

top 1 20

The above command will return the first 20 lines of email number one on the server, not including the email headers.

If like me, you receive a lot of spam, then you might want to delete an email without actually downloading it. This is accomplished using the dele command.

dele 1

The server should respond with a success code:

+OK Marked to be deleted

Be very careful when using this command, as any email messages deleted using this method are irretrievable and gone forever. There are no “Trash” or “Deleted Items” folders on the server.

As a side note, these commands are part of the official POP3 standard, and as such are the commands used by all email programs to retrieve email from POP email servers. (IMAP is a different standard, and uses different commands.)

If you want to send an email, then a different protocol must be used: SMTP, and that’s another post.