Electronic mail is possibly the most wide-spread use of the Internet. It is also potentially the most varied and complex. Through the years many, many programs and documents have been written to standardize and simplify the electronic mail transaction. Thanks to these efforts, electronic mail these days has become a ubiquitous part of life on the Internet.
For users, electronic mail is usually rather simple. A large number of programs are available for composing and reading email. These programs are known as mail user agents (MUAs). Some examples include: pine, elm, MH, Mail, exmh, Eudora, etc. However, for the system administrator, the transport and delivery of electronic mail can sometimes be a headache.
Mail delivery agents (MDAs) are programs responsible for actually delivering mail to a user. MDAs usually handle one specific type of mail delivery. On Unix systems this is typically the program /bin/mail, which is responsible for putting email into a user's local mailbox file. Other MDAs include: uux, for delivering UUCP mail; procmail, for advanced filtering of mail before delivery.
Mail transport agents (MTAs), also called mail transfer agents, handle everything needed to get a mail message from a mail user agent to a mail delivery agent ... which can be a whole lot. MTAs route email messages, whether locally or remotely, they interpret aliases, they re-write addresses in order to hand them off to appropriate mail delivery agents, they relay mail from other transport agents, they queue currently undeliverable mail for later transport, and much more. Mail transport agents are the quintessential middle man. The MTA is where a system administrator does most of the work configuring and administrating mail, so it is where this topic concentrates its focus.
The predominant mail transport agent in the Unix world is sendmail. There are several differing versions of sendmail (Berkeley and IDA sendmail being the most well known), as well as alternative MTAs such as smail. This topic will cover Berkeley sendmail.
Sendmail uses the TCP-based, client-server simple mail transfer protocol (SMTP) to transport mail between Internet hosts. SMTP is explained in detail in the optional reading, Request for Comments number 821, a.k.a, RFC821. As the name suggests, SMTP is a very simple protocol consisting of four-character commands and three-digit reply codes. The protocol is simple enough that one can use it simply by telnetting directly to the SMTP port, 25 (although this method doesn't provide the level of functionality or versatility of a standard mail user agent). An extended version of SMTP, ESMTP is now also widely used.
To see an example of the simplicity of an SMTP transaction (this particular one actually uses ESMTP), try out or follow along with this example. First create a file containing a bit of text, call it message for our purposes, although the name doesn't matter. Now invoke sendmail directly to mail this file as an email message and watch the conversation as it happens (the Unix shell prompt is shown here with the $ prompt):
$ /usr/lib/sendmail -v brier@indiana.edu < message brier@indiana.edu... Connecting to mail-relay.indiana.edu. via smtp... 220 belize.ucs.indiana.edu ESMTP Sendmail 8.7.3/8.7.3/1.10IUPO; Wed, 26 Jun 1996 00:03:05 -0500 (EST) >>> EHLO outland.uwsg.indiana.edu 250-belize.ucs.indiana.edu Hello outland.uwsg.indiana.edu [129.79.17.234], pleased to meet you 250-8BITMIME 250-SIZE 250-DSN 250-VERB 250-ONEX 250 HELP >>> MAIL From:<brier@outland.uwsg.indiana.edu> SIZE=24 250 <brier@outland.uwsg.indiana.edu>... Sender ok >>> RCPT To:<brier@indiana.edu> 250 Recipient ok >>> DATA 354 Enter mail, end with "." on a line by itself >>> . 250 AAA26262 Message accepted for delivery brier@indiana.edu... Sent (AAA26262 Message accepted for delivery) Closing connection to mail-relay.indiana.edu. >>> QUIT 221 belize.ucs.indiana.edu closing connection
The transaction consists of only five commands: a greeting between the client and the server (EHLO), a specification of the sender (MAIL), a specification of the recipient (RCPT), the entry of the data of the message (DATA), and an end to the transaction (QUIT).
The format of email messages is specified in RFC822 (optional for this course). An internet email message consists of a header and a body. The fields of the header are keyword/value pairs separated by a colon. Certain header fields are required by RFC822, and many others are optional and give information about the message. Many of the fields of less use to the average user are hidden by most user agents (although the shown headers are often configurable).
It is useful to study the header fields of mail messages to see what kind of information you can discover about the mail message and where it has been. For instance, look at this example message (the lines of some fields have been wrapped and indented 4 spaces to be more readable):
Return-Path: brier@outland.uwsg.indiana.edu Delivery-Date: Tue, 25 Jun 1996 23:13:18 -0500 Return-Path: brier@outland.uwsg.indiana.edu Received: from cayman.ucs.indiana.edu (cayman.ucs.indiana.edu [129.79.10.63]) by outland.uwsg.indiana.edu (8.7.5/8.7.3) with ESMTP id XAA17021 for <brier@outland.uwsg.indiana.edu>; Tue, 25 Jun 1996 23:13:17 -0500 (EST) Received: from poboxer.pobox.com (root@poboxer.pobox.com [207.8.188.2]) by cayman.ucs.indiana.edu (8.7.3/8.7.3/1.10IUPO) with ESMTP id XAA29472 for <brier@indiana.edu>; Tue, 25 Jun 1996 23:14:03 -0500 (EST) Received: from roatan.ucs.indiana.edu (roatan.ucs.indiana.edu [129.79.10.65]) by poboxer.pobox.com (8.7.1/8.7.1) with ESMTP id AAA17567 for <brier@pobox.com>; Wed, 26 Jun 1996 00:13:14 -0400 Received: from outland.uwsg.indiana.edu (outland.uwsg.indiana.edu [129.79.17.234]) by roatan.ucs.indiana.edu (8.7.3/8.7.3/1.10IUPO) with ESMTP id XAA22553 for <brier@pobox.com>; Tue, 25 Jun 1996 23:13:38 -0500 (EST) Received: from outland.uwsg.indiana.edu (localhost [127.0.0.1]) by outland.uwsg.indiana.edu (8.7.5/8.7.3) with ESMTP id XAA17012 for <brier@pobox.com>; Tue, 25 Jun 1996 23:13:13 -0500 (EST) Message-Id: <199606260413.XAA17012@outland.uwsg.indiana.edu> To: brier@pobox.com Subject: An example mail message Date: Tue, 25 Jun 1996 23:13:12 -0500 From: Chris Brierley <brier@indiana.edu> This text is the body of the message.
The header fields of this message provide a lot of information, from the obvious fields such as From:, To:, and Subject:, to the less intuitive, but greatly useful Received: fields. Take a look at those Received: fields. They outline the trail that the mail message took in it's journey from sender to recipient. The Received: fields are tacked on to the top of the message by each MTA it encounters. Reading the fields as if they were sentences, starting at the lowest Received: field and working up to the topmost field, shows that this mail message traveled from outland.uwsg.indiana.edu to roatan.ucs.indiana.edu to poboxer.pobox.com to cayman.ucs.indiana.edu and finally back to outland.uwsg.indiana.edu.
These header fields are an important resource when debugging electronic mail problems. Do not let your MUA make you forget about them by hiding them from you.
Terms used: MUA, MDA, UUCP, MTA, sendmail, SMTP, TCP, RFC.