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. 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."

Table of contents:
Evolved
Code
ASP, SQL & VB meet the internet.

Navigate

Home Parent Directory Meta-Search

Technical

ASP Scripts SQL Scripts VB Programs Show All

Guides

Show All

Other

Contact Site News About Legal Sitemap Links