The
-v
command-line switch tells
sendmail
to run in
verbose
mode. In that mode,
sendmail
prints a blow-by-blow [4] description of all the steps it takes in delivering a mail message. To watch
sendmail
run in verbose mode, send mail to yourself as you did in
Section 1.4, "Run sendmail by Hand"
, but this time add a
-v
switch:
[4] Verbose mode is actually far more powerful than we've shown here.
%/usr/lib/sendmail -v
you
< sendstuff
The output produced shows that sendmail delivers your mail locally:
you
... Connecting to local...
you
... Sent
When
sendmail
forwards mail to another machine over a TCP/IP network, it communicates with that other machine using a protocol called SMTP (Simple Mail Transfer Protocol). To see what SMTP looks like, run
sendmail
again, but this time, instead of using
you
as the recipient, give
sendmail
your address on another machine.
%/usr/lib/sendmail -v
[email protected]
< sendstuff
The output produced by this command line will look similar to the following:
[email protected]... Connecting to remote.domain via smtp...
220-remote.Domain Sendmail 8.6.12/8.5 ready at Fri, 13 Dec 1996 06:36:12 -0800
220 ESMTP spoken here
>>> EHLO here.us.edu
250-remote.domain Hello here.us.edu, pleased to meet you
250-EXPN
250-SIZE
250 HELP
>>> MAIL From:<[email protected]>
250 <[email protected]>... Sender ok
>>> RCPT To:<[email protected]>
250 <[email protected]>... Recipient ok
>>> DATA
354 Enter mail, end with "." on a line by itself
>>> .
250 GAA20115 Message accepted for delivery
[email protected]... Sent (GAA20115 Message accepted for delivery)
Closing connection to remote.domain
>>> QUIT
221 remote.domain closing connection
The lines that begin with numbers and the lines that begin with
>>>
characters constitute a record of the SMTP conversation. We'll discuss those shortly. The other lines are
sendmail
on your local machine telling you what it is trying to do and what it has successfully done:
[email protected]... Connecting to remote.domain via smtp...
...[email protected]... Sent (GAA20115 Message accepted for delivery)
Closing connection to remote.domain
The first line shows to whom the mail is addressed and that the machine
remote.domain
is on the network. The last two lines show that the mail message was successfully sent.
In the SMTP conversation your local machine displays what it is saying to the remote host by preceding each line with
>>>
characters. The messages (replies) from the remote machine are displayed with leading numbers. We now explain that conversation.
220-remote.Domain Sendmail 8.6.12/8.5 ready at Fri, 13 Dec 1996 06:36:12 -0800
220 ESMTP spoken here
Once your sendmail has connected to the remote machine, your sendmail waits for the other machine to initiate the conversation. The other machine says that it is ready by sending the number 220, a dash (to say that it has more to say), and its fully qualified hostname (the only required information). If the other machine is running sendmail , it also says the program name sendmail and the version. It also states that it is ready and gives its idea of the local date and time.
The second line also starts with a 220, but that 220 is not followed by a dash. A dash means that more lines will follow, and the absence of a dash means that this is the last line.
The "ESMTP spoken here" means that the remote site understands the Extended SMTP protocol. If the other machine were running V8.7 or later
sendmail
, the ESMTP would precede
Sendmail
in the first line, and there would be no second line.
If sendmail waits too long for a connection without receiving this initial message, it prints "Connection timed out" and queues the mail message for later delivery.
Next the local
sendmail
sends (the
>>>
) the word
EHLO
, for Extended Hello, and its own hostname:
>>> EHLO here.us.edu
250-remote.domain Hello here.us.edu, pleased to meet you
250-EXPN
250-SIZE
250 HELP
The E of the
EHLO
says that the local
sendmail
speaks ESMTP too. The remote machine replies with
250
and the acknowledgment that your hostname is acceptable, then lists the ESMTP services that it supports.
One problem that could occur is your machine sending a short hostname ("here") in the
EHLO
message.
This would cause an error because the remote machine wouldn't find
here
in its domain
remote.domain
. This is one reason why it is important for your
sendmail
to always use your machine's fully qualified hostname. A fully qualified name is one that begins with the host's name, followed by a dot, then the entire DNS domain.
If all has gone well so far, the local machine sends the name of the sender of the mail message:
>>> MAIL From:<[email protected]>
250 <[email protected]>... Sender ok
Here, that sender address was accepted by the remote machine.
Next the local machine sends the name of the recipient:
>>> RCPT To:<[email protected]>
250 <[email protected]>... Recipient ok
If the user
you
were not known on the remote machine, it would reply with an error of "User unknown." Here, the recipient is
ok
. Note that
ok
does not necessarily mean that the address is good. It can still be bounced later. The
ok
means only that the address is acceptable.
After the envelope information has been sent, your sendmail attempts to send the mail message (header and body combined).
>>> DATA
354 Enter mail, end with "." on a line by itself
>>> .
DATA
tells the remote host to "get ready." The remote machine says to send the message, and the local machine does so. (The message is not printed as it is sent.) A dot on a line by itself is used to mark the end of a mail message. This is a convention of the SMTP protocol. Because mail messages may contain lines that begin with dots as a valid part of the message,
sendmail
doubles any dots at the beginning of lines before they are sent. [5] For example, consider when the following text is sent through the mail:
[5] This is called the "hidden dot algorithm" and is documented in RFC821.
My results matched yours at first:
126.71
126.72
...
126.79
But then the numbers suddenly jumped high, looking like
noise saturated the line.
To prevent any of these lines from being wrongly interpreted as the end of the mail message, sendmail inserts an extra dot at the beginning of any line that begins with a dot, so the actual text transferred is
My results matched yours at first:
126.71
126.72
.... note extra dot126.79
But then the numbers suddenly jumped high, looking like
noise saturated the line.
The SMTP-server program running at the receiving end (for example, another sendmail ) strips those extra dots when it receives the message.
The remote sendmail shows the queue identification number that it assigned to the mail it accepted:
250 GAA20115 Message accepted for delivery
>>> QUIT
221 remote.domain closing connection
The local
sendmail
sends
QUIT
to say it is all done. The remote machine acknowledges by closing the connection.
Note that the
-v
(verbose) switch for
sendmail
is most useful with mail sent to remote machines. It allows you to watch SMTP conversations as they occur and can help in tracking down why a mail message fails to reach its destination.