SMTP: The mail protocol for the internet
SMTP is used to transfer mail between machines that are continually
on the internet, as well as to send mail from a dialup system to another
host on the internet. SMTP makes no attempt to authenticate users or
systems; the very nature of the network makes such authentication impossible.
SMTP transactions occur on port 25.
Unlike POP3, commands in SMTP need to be in a particular order. Before any other
commands are accepted, the computers need to perform something called handshaking.
In this, the originating system (you) says HELO my.fully-resolved.hostname. The
other system should give you a similar response.
After saying HELO, the user states the origin of the message using
Secondly, the user states a list of recipients of the message, using
This command is issued once for each recipient. Then, the DATA
command is issued. After this command is issued, all following text
is considered to be headers and message body. To terminate a message, a line with just
a period is entered. The QUIT command closes the connection.
Here is an example of using SMTP to send a message:
$ telnet mail.foo.bar 25
Connected to smtp.foo.bar.
Escape character is '^]'.
220 smtp.foo.bar ESMTP Sendmail 8.8.7/8.8.6; Wed, 3 Dec 1997 20:20:43 -0500 (EST)
250 smtp.foo.bar Hello dialup [192.168.1.2], glad to see you.
250 email@example.com... Sender ok
250 firstname.lastname@example.org... Recipient ok
250 email@example.com... Recipient ok
354 Enter mail, end with "." on a line by itself
From: firstname.lastname@example.org (Pat Gunn)
Subject: Hi there! (test message)
Hi Pat! How are you doing?
I've been bored recently.
250 UAA22108 Message accepted for delivery
221 smtp.foo.bar closing connection
Connection closed by foreign host.
In this example, I sent an email message with a listed from line as
email@example.com, to firstname.lastname@example.org and to email@example.com.
It is worthy of note that if I deleted the To: line in the headers
of my message (the one AFTER DATA), the recipients
of my message would not see who the message is to, and thus would be
unaware that my message was sent to more than one person. This is the
way that Bcc: works in modern Email software. Common headers that you will
want to type include:
SMTP is described in RFC788
- Subject: My_Subject