Trivial uses of Telnet - SMTP
Continued from
page 4 - "Reading your e-mail simply, quickly and from anywhere on the planet - the POP3 protocol."
SMTP - outgoing e-mail
SMTP stands for
Simple
Mail
Transfer
Protocol; this is the majority of the internet
sends its messages and from time to time it is a very useful thing to know how this works. Standards suggest that
the SMTP service should listen on port 25, although again it is trivial to reconfigure the service to listen on
another port.
Commands required to use SMTP proficiently are very few, but to start using it "creatively" you
need to understand what it's doing. Similar to POP3 the service uses text comments along side a status marker,
however under SMTP these are more detailed status codes rather than a general state so all the computer needs to
worry about is the codes - the text is simply there to make the protocol accessible to end-users accessing the
service via direct connection. These messages take the form
{code} {text} as you will see in the
examples below.
-
HELO - a way to set an identity to be used for sending this mail, mostly this is just for show
as the service will automatically detect the correct name for yourself, since if this worked as expected
mail would be so easy to fake. For the sake of complying to the specification it does need some text
after it so that the command gets accepted.
-
EHLO - another way to set an identity to be used for sending this mail, mostly this is just for show
as the service will automatically detect the correct name for yourself, since if this worked as expected
mail would be so easy to fake. For the sake of complying to the specification it does need some text
after it so that the command gets accepted.
-
MAIL FROM: - defines the e-mail address of the sender of the message.
-
RCPT TO: - defines the e-mail address of a recipient of the message. Repeating this command
once for each recipient means you can send one piece of mail to many users without having to repeat the
entire process over and over again.
-
DATA - marks the start of the data portion of the message, essentially everything that you would
consider "content", this includes the "To:", "From:", "CC:" etc.
as these are all simple components which your e-mail client picks out of the content and displays in a far
nicer format. Just as a reminder - anything which is in the content can be faked as it is content and so
consequently cannot be validated.
-
.{ret}{ret} - this sequence of a period and two carriage returns marks the end of the data portion
of the message, if you wish to use a period in a message normally you would use two periods.
-
QUIT - closes your connection to the service.
Below is an example of how to send a very simple message via SMTP;
220 smtp.example.com ESMTP Sendmail 8.9.2/8.9.2/Debian/GNU; Sat, 9 Jun 2001 12:27:28 +0100 (BST)
HELO user123.example.com
250 smtp.example.com Hello user123.example.com [10.0.0.100], pleased to meet you
MAIL FROM: user123@example.com
250 user123@example.com Sender ok
RCPT TO: test@example.com
250 test@example.com Recipient ok
DATA
354 Enter mail, end with "." on a line by itself
Hello
.
250 MAA31024 Message accepted for delivery
QUIT
221 smtp.example.com closing connection
The next step along would be a basic e-mail which conforms much more to what a e-mail client expects
an e-mail to look like. This example creates a plain text e-mail and sets MIME types, includes a neat
version of the to: and from: data, uses a subject line and applies a content type before setting the
header. From this example onwards I am not going to bother including server responses since they are
all identical and just serve to confuse the information further.
HELO user123.example.com
MAIL FROM: user123@example.com
RCPT TO: test@example.com
DATA
MIME-Version: 1.0
From: Me <user123@example.com>
To: You <test@example.com>
Subject: Simple standardised email
Content-type: text/plain; charset=US-ASCII
Hello. Content goes here.
.
QUIT
Continued on
page 6 - "Sample scripts showing basic SMTP protocol operations as well as a few more advanced examples."