Transfer agents are responsible for properly routing messages to their
destination. While their function is hidden from the average user, theirs is
by far the most complex part of getting messages from their source to their
destination. The most common transfer agent is sendmail(1m).
mail.local(1m).
Each recipient address on a mailing list or alias can be an ordinary user or another mailing list or alias. These recipients can be at different hosts or all at the same; it doesn't matter.
The most common character set is US-ASCII, which has 32 (non-printable) control characters and 96 (mostly printable) other characters, for a total of 128. These 128 characters can be encoded in 7 bits of data, so each 8-bit byte representing one of these characters has the lower 7 bits set to the appropriate value for the given character and the 8th (high) bit set to zero. US-ASCII is therefore considered a single-byte 7-bit character set.
Many European languages have accentuated characters (like the German ü, the French ç and é, the Danish ø and the Spanish ñ). Such languages are commonly represented by characters sets whose lower half (i.e., values 0 - 127) are identical to those of US-ASCII, and whose upper half (i.e., values 128 - 255) represent these accentuated characters. These are therefore considered single-byte 8-bit characters sets; an example is ISO-8859-1.
Many Asian languages have so many characters that they need multiple bytes to represent them all. They are therefore considered multiple-byte character sets.
A blank line always separates the headers from the body.
The body contains the information the sender is trying to communicate. The "message" as most people think of it is really the body of the message.
MIME (Multipurpose Internet Mail Extensions, specified in RFCs
2045 - 2049, especially RFC
2045 and RFC 2046,
defines such a body structure. It specifies how a Content-Type
header can be used to specify a particular character set or other non-textual
data type for a message. For example, the header:
Content-Type: text/plain; charset=us-asciiindicates that the message consists of plain text in the US-ASCII character set. MIME also specifies how to encode data when necessary (more on this below). It is the responsibility of the receiving user agent to use this information to display the message in a form that will be understood by the user.
The SMTP body is the entire message as defined above in Headers & Bodies. So the message headers plus the message body equals the SMTP body. The term SMTP body is not used that commonly, but it is important to distinguish it from the message body.
By the 1990s, however, several factors had increased the need for 8-bit message transfer. As mentioned above, European languages often use 8-bit character sets, and Asian language character sets often require multiple bytes; their transmission is greatly simplified if all 8 bits can be transferred unaltered. Finally, the explosion of multi-media messages like audio and video clips have brought about a two-fold need for 8-bit message transfer: encoding messages into 7-bit data is not only cumbersome, but the resultant encoded message is significantly (typically 33%) larger than the original message.
To meet this need, SMTP has been extended to allow 8-bit data to be properly transferred between consenting transfer agents. The negotiating process used to verify consent is specified in RFC 1869, which describes the general extension mechanism to SMTP (called ESMTP), and RFC 1652, which describes the specific extension to allow 8-bit data transfer, called 8BITMIME. If a transfer agent has a message containing 8-bit data and it cannot negotiate the proper transfer of that data, it must either encode the message into 7-bit data using MIME, or return the message to the sender indicating the reason for the return.
It is no coincidence that MIME and ESMTP have common rationales and goals; they were developed in conjunction with each other towards the same end.
Mail eXchanger (MX) records are maintained by domain name servers (DNS) to tell MTAs where to send mail messages. An MX record can be specified for a specific host, or a wild-card MX record can specify the default for a specific domain. The MX record tells an MTA where a message, whose ultimate target is a given host in a given domain, should be sent to next, i.e., which intermediate hosts should be used to ultimately deliver a message to the target host. These MX records vary depending on the domain. To illustrate, here is an an example of how a message from a.eng.sun.com destined for b.ucsb.edu might be routed:
The MTA on a.eng.sun.com looks up the MX record for b.ucsb.edu, which tells it to route the message to venus.sun.com. The MTA on venus.sun.com looks up the MX record for b.ucsb.edu, which tells it to route the message to hub.ucsb.edu. The MTA on hub.ucsb.edu looks up the MX record for b.ucsb.edu, which tells it to route the message directly to b.ucsb.edu. The MTA on b.ucsb.edu recognizes that the message has arrived at its intended destination and processes the message for local delivery.
The gethostbyname() library routine may use DNS, an
/etc/hosts file, or some other name service (e.g., NIS,
LDAP, ...) to perform its name-to-IP-address look-up, as configured by the file
/etc/nsswitch.conf (on Solaris; /etc/service.switch
is used on other OSs). N.B.: the host name passed to
gethostbyname() may have been derived from an MX record if a
domain name server is running, even though gethostbyname() may
not use DNS to resolve this name's address. Remember that MX records are only
available from DNS, and the name service switch does not affect a search for
MX records. This is as required by
RFC 1123, section
5.3.5. This situation may be most noticeable when DNS is not first in
the /etc/nsswitch.conf file. It may then be possible that a host
name only in /etc/hosts or NIS (for example) be redirected by a
wild-card MX record to another host.
mailcap
configuration file. For example, the following line (broken into 3 lines
here for readability) could be used to display text in the ISO-8859-1
character set:
text/plain; shownonascii myfont %s; \
test=test "`echo %{charset} | tr A-Z a-z`" = iso-8859-1; \
copiousoutput
This line tells metamail that when it sees a message of type
text/plain, whose charset parameter,
when mapped to lower-case, is iso-8859-1, it should
invoke the script shownonascii with the argument
myfont. The shownonascii script is provided
with metamail, and invokes a terminal emulator program with the specified
font.
metamail first looks in $HOME/.mailcap, then
/etc/mail/mailcap, so a user's local preferences take precedence
over the system ones. To add support for a new character set, a user
need only add a line like the one above to his or her mailcap file,
with iso-8859-1 replaced by the actual character set, and
myfont replaced by the required font. Likewise, a system
administrator can add such a line to the system mailcap file.
metamail also can display non-textual parts of messages. The mailcap file can be configured in a similar way, for example:
image/*; showpicture -viewer /usr/local/bin/X11/xv %s
tells metamail to display all messages of type image by invoking the
showpicture script with the xv viewer. The
showpicture, showaudio and showexternal
scripts are all provided as part of the metamail package.