Using CPC/IP's telnet to read and send email and posts, and to surf

It's possible to use CPC/IP's telnet to read and send email and posts, and even to surf the net a bit, albeit with a degree of comfort the Spanish Inquisition would be proud of.

General considerations

Always use CPC/IP telnet's -l switch to enable line mode. If you don't, then any mistype will probably corrupt the line being entered. You can only send a line if the previous line has been received by the remote side; if when you press Return CPC/IP beeps at you and leaves the cursor where it is, then wait a bit and try again. Typically, you'll know when the previous line has been received by the remote side because some kind of response will be displayed.

Generally, the procedure is to telnet to the so-called 'well-known' port (by typing the port number after the server address) and then to type in commands, with optional arguments (use a single space to separate any arguments). Commands are case-insensitive, unless otherwise specified. Command arguments are sometimes case-sensitive; when in doubt preserve case. Command parameters are shown in angle brackets below; you need to replace them with your chosen command argument.

You sometimes need to enter sensitive information such as passwords. To foil all those prying eyes, use Ctrl-E before entering the sensitive information, and Ctrl-E again when it's been entered.

Needless to say, the information below is only the tip of the iceberg. For more information look at the RFCs. If things go really really bad, then Ctrl-[ is your friend!

Reading email using POP3

Port number: 110

Server address: typically pop3.*

RFC: RFC1939

POP3 works by giving each message in your mailbox a number starting from 1. That number is how you tell a POP3 server which message you want to deal with.

Step 1: logging on

Use user <username> and then pass <password> to log on.

Step 2: reading your email

Use stat to get a count of the total number of messages in your mailbox, and their total size. Use list to get a list of all the messages' numbers and sizes. Use retr <number> to read (retrieve) a message. Use dele <number> to mark a message for deletion; if you change your mind you can use rset to unmark all messages marked for deletion. Use top <number> <lines>, if provided by your POP3 server, to read the first few lines of a message; this can be useful if the message is huge and you're not sure you're interested! Use quit to disconnect. At this point, and only at this point, messages you marked for deletion are deleted from your mailbox (so if your connection terminates abnormally, before you've typed quit, nothing is lost). Note, however, that some POP3 servers may choose to auto-delete any messages which have been retrieved, even if not explicitly marked for deletion.

Example POP3 session

> telnet -l pop3.isp.com 110
        ; We're connected!
user cpcip
pass k00lDUDE3!
        ; We're logged in!
stat
        ; Oooh, three messages waiting for me!
list
        ; OK, they're all fairly small
retr 1
        ; Spam
dele 1
        ; No spam
retr 2
        ; It's from Archibald!  I must phone him right now
quit
        ; I'll keep 1 and read 3 another day

Posting email using SMTP

Port number: 25

Server address: typically mail.* or smtp.*

RFCs: RFC821, RFC822

An email message consists of a header and a body. The header contains the kind of stuff you get at the top of a letter: who the message is from, who it is to, the date, etc.. SMTP takes this message, and delivers it to the right person, given an envelope telling it whom to send it to and who it is from.

Step 1: working out which SMTP server to speak to

You can't telnet to the SMTP server without knowing which SMTP server to telnet to. To determine this, use CPC/IP's DNS client: use host -m <domain>, where the domain is the bit after the @ in the email address. Pick one of the mail exchanges given (preferably the one with lowest preference number); that's the SMTP server you need to telnet to. If the DNS lookup fails, then you'll just have to try the domain itself and hope for the best.

Step 2: specifying the envelope

OK, so you've telneted into the right SMTP server. Use helo <domain> to say which machine you're on and then mail from: <addr> to say who you are. Then use rcpt to: <addr> one or more times to say who the message is to. Note that addresses should be enclosed in angle brackets.

Step 3: giving the message

Use data to say that you now want to enter the message. The message consists of the header, then a blank line, then the body, then a line consisting of just a dot. Any lines starting with dots in the body should have another dot added at the start of the line.

The header consists of lines each containing a field name, a colon and the field value. The fields can be in any order. The only mandatory ones are From, To (or some other destination specification) and Date. From is followed by an email address, which need not have angle brackets; To is the same, except that more than one address can be given, separated by commas. If you're lucky, then your SMTP server will accept messages without a Date field, else you'll have to come up with one of the godawful date formats allowed by RFC822.

The optional fields include Subject, Reply-To and cc; the latter two are followed by one or more addresses, like To.

When you've finished (don't forget the line with just a dot!), you can just use quit to finish, or start again with a fresh message to someone at the same domain, starting with the mail from:.

Example SMTP session

> host -m koaks.com
        ; Ah, I'd better speak to mail.koaks.com, though I could use mailtoo 2
> telnet -l mail.koaks.com 25
        ; We're connected!
helo bufo-house.org
        ; Why, helleugh!
mail from: <cpcip@bufo-house.org>
rcpt to: <info@koaks.com>
rcpt to: <mark@koaks.com>
data
        ; OK, here goes...
From: ams@bufo-house.org
To: info@koaks.com, mark@koaks.com
Date: Tue, 29 Feb 2400 12:34:50 GMT
Subject: Site licence
Reply-To: purchasing@bufo-house.org

I would like to buy a site licence for CPC/IP.
Please tell me how many cubic metres of euros would be needed.

Alan

-- 
Bufo House, a Bufo Estates company
..This line gratuitously starts with a single dot; the next one just has a dot
..
.
        ; Phew!
quit
        ; Aaargh, I forgot to specify the currency unit size!

Reading and posting news using NNTP

Port number: 119

Server address: typically news.* or nntp.*

RFCs: RFC977, RFC1036

Posts are very similar to email messages in that they consist of a header and a body. There are a few extra fields, and various outrageous forms allowed in email messages (especially for email addresses) are forbidden, though.

Articles in a given group on a given NNTP server are numbered; this number has no significance in another group or on another NNTP server.

Step 1: reading some news

Use group <name> to select a group. The response from the NNTP server will confirm, from right to left, the group name, the last article number in that group, and the first article number in that group.

Use stat <number> to select a message. Then use body to retrieve that message's body, head to retrieve that message's header, and article to retrieve both. Use last to select the previous message, and next to select the next message.

Step 2: posting some news

Use post to say you want to post a message. The content is similar to that of an email message (so it's header then blank then body with any leading dot duplicated then line with just dot), but there's no To field, and the Subject field is mandatory. The To field is replaced by a Newsgroups field, which takes one or more comma-separated group names. A Path field and a Message-ID field are in principle mandatory, but just pray that your NNTP server will insert these for you!

Incidentally, the first response from the NNTP server when you connected to it will tell you whether you're allowed to post or not; if it started 200 then you are, but if it started 201 then you aren't.

Step 3: going to bed

Use quit.

Example NNTP session

> telnet -l news.isp.com 119
        ; We're connected!
group comp.sys.amstrad.8bit
        ; Ah, the last article number is 666
stat 666
head
        ; This looks like spam
last
head
        ; This looks interesting
body
        ; What?  That Speccy owner can't be allowed to get away with this
post
        ; OK, here goes...
From: ams@bufo-house.org
Newsgroups: comp.sys.amstrad.8bit,comp.sys.sinclair
Date: Wed, 10 Mar 1987 17:12:34 GMT
Subject: Re: Amstrad buys Sinclair
Followup-To: alt.flame

No, it was an act of selfless charity.  You should be more grateful!
.
        ; That'll teach her!
quit

Surfing the net using HTTP

Port number: 80

Server address: typically www.*

RFC: RFC2068

The WWW nowadays is 99% fluff and 1% content, and this applies both to the sites and to the pages. So you'll have to have a sharp eye to spot the content among the crap as it scrolls past. But feel free to try.

Step 1: fetching

First type GET <pathname> HTTP/1.0, where the pathname is the bit after the hostname in the URL (including the leading slash). Then type Host: <hostname>. Then enter a blank line. All of this is case-sensitive. The connection will automatically be closed when the page (or error message!) has been transferred.

Incidentally, if the URL has a colon and a number after the hostname, that indicates a non-default port number, which you should use instead of 80.

Example HTTP session

> telnet -l www.nenie.org 80
        ; We're connected!
GET / HTTP/1.0
Host: www.nenie.org

        ; Oooh, what an uncommonly nice homepage this is!

Mark RISON, <mrison@hotmail.com>, 2001-06-03

Thanks to Franck ARNAUD for hosting these pages.

Valid HTML 3.2!