Previous Section Next Section

Received:

Trace routing of mail RFC2822

The Received: header is used to record information about every site a mail message passes through on its way to ultimate delivery. First this header is inserted by the original sending site, then another is added by each site that the message passes through, including the site performing final delivery. Each new header is added to the list of Received: headers, forming a chronological record (reading bottom up through the headers) of how the mail message was handled.

The contents of the Received: header's field are narrowly defined by RFC2821. The field's defined form looks like this:

Received: "from" host "by" host ["via" atom] ["with" atom]
       ["id" string] ["for" addr] ";" date
    
   whitespace

The field is composed of six items that can be split over multiple lines by using whitespace to indent the second line. Each item is composed of two parts: a word (shown in quotation marks) and a value. Optional items are indicated by the enclosing square brackets in the previous example, but those brackets are not a part of the item and must be excluded when the item is actually used. Items, when present, must be in the following order:

from

Full canonical name of the sending host (required).

by

Full canonical name of the receiving host (required).

via

Physical network that was used to transmit the message, such as TCP, INTERNET, JANET, or XNS (optional).

with

Protocol used to receive the message, such as ESMTP or SMTP (optional).

id

Identifier assigned by the local host, such as the Message-Id: header's value (optional).

for

Initial, untranslated address of the recipient—when there is a single recipient, sendmail always includes this item (optional).

;date

Date this message was received (required).

The Received: header must be declared in the configuration file. It is a mandatory header, so it should never be prefixed with ?flags?. The typical declaration of this header has evolved from version to version of sendmail (some of these examples have been wrapped to fit the page):

V8.12:
HReceived: $?sfrom $s $.$?_($?s$|from $.$_)
        $.$?{auth_type}(authenticated$?{auth_ssf} bits=${auth_ssf}$.)
        $.by $j ($v/$Z)$?r with $r$. id $i$?{tls_version}
        (version=${tls_version} cipher=${cipher} bits=${cipher_bits}
        verify=${verify})$.$?u               line wrapped to fit page
        for $u; $|;
        $.$b
V8.11:
HReceived: $?sfrom $s $.$?_($?s$|from $.$_)
        $.$?{auth_type}(authenticated$?{auth_ssf} (${auth_ssf} bits)$.)
        $.by $j ($v/$Z)$?r with $r$. id $i$?{tls_version}
        (using ${tls_version} with cipher ${cipher} (${cipher_bits} bits)
        verified ${verify})$.$?u            line wrapped to fit page
        for $u; $|;
        $.$b
V8.10:
HReceived: $?sfrom $s $.$?_($?s$|from $.$_)
        $.$?{auth_type}(authenticated)
        $.by $j ($v/$Z)$?r with $r$. id $i$?u
        for $u; $|;
        $.$b
V8.9:
HReceived: $?sfrom $s $.$?_($?s$|from $.$_)
        $.by $j ($v/$Z)$?r with $r$. id $i$?u
        for $u; $|;
        $.$b

The complexity of the Received: header has changed mostly due to the addition of authentication information. Despite those additions, however, the following seven key items remain common among all the versions:

$?sfrom $s $.

If the $s macro contains a value, the word from and that value are inserted into the header. The $s macro ($s) contains the full canonical name of the sender's host.

$?_($?s$|from $.$_) $.

This is a nested conditional. If the $_ macro contains a value, the parentheses and all the information inside them are inserted into the header. If the $_ macro lacks a value, this information is not inserted into the header.

Inside the parentheses the value of $_ is inserted into the header. Another conditional expression determines if the $_ just inserted should also be prefixed with the word from. If the $s macro lacks a value, the word from is inserted in front of the $_. The $_ macro contains the RFC1413 identd(8) identity of the connecting host and any IP routing information ($_).

by $j ($v/$Z)

The $j macro contains the full canonical name of the local host. The parentheses surround a comment that is formed from $v ($v), the version of the sendmail program, and $Z ($Z) the version of the configuration file.

$?r with $r$.

If the $r macro contains a value, the word with followed by the value of $r are inserted into the header. The $r macro ($r) contains a string that indicates the protocol used to receive the message (such as SMTP or ESMTP).

id $i

The $i macro contains the identifier created by sendmail to uniquely identify this mail message at this host ($i).

$?u for $u$.

If the $u macro contains a value, the word for followed by the value of $u is inserted into the header. The $u macro ($u) contains the recipient's username.

; $b

The $b macro contains the current date and time in RFC2822 format ($b).

The Received: declaration shown earlier is the one typically used by most sites running V8 sendmail.

    Previous Section Next Section