Heirloom Project

☞ Home
☞ Toolchest
☞ Bourne Shell
☞ Documentation Tools
☞ Development Tools
☛ mailx
⌊ History
⌊ aux.c
☞ Packaging Tools
☞ vi

mail, Mail, mailx, nail—history notes

There has since long been confusion about the names of mail commands on Unix systems. Here is some clarification:

The most ancient command is mail, which was included in Unix 1st Edition in 1971 according to the manuals. At this time, Unix had no remote communication facility at all, so mail would simply write to other users' files on a single machine.

mail has since been updated a bit in following Unix versions; it could invoke uux and later sendmail for sending remote messages and got at least some interactive commands for navigating in a mailbox. A mail command like this was standardized with the System V Interface Definition (SVID) and the Single Unix Specification (up to the 1998 edition).

With later versions of System V, mail still got some more features, e. g. a facility to print header summaries. An Open Source version of such a mail command is available as part of the Heirloom Toolchest package; see its manual page for an overview of its features. Yet all derivatives of the original mail remained somewhat primitive; since they neither invoke a pager for viewing messages longer than a CRT screen, nor offer a method to set Subject lines, they are not well suited for use with Internet mail. They are still appropriate to send short messages, though.

What one should learn from this is, however, that any use of a mail command with the -s option to set a subject line in a shell script is unportable and will not work on some Unix implementations.

In 1978, Kurt Shoens wrote another mail user agent for Unix: Berkeley Mail. It was not a derivative of the original mail command. At the time it was included in the 2BSD release (which still was just an add-on for Unix 6th or 7th Edition systems), its user interface was already complete (so if the bsdcompat option is set in Heirloom mailx, it practically looks and feels the same). After installation, Berkeley Mail was found as /usr/ucb/Mail, but Unix mail was still available as /bin/mail.

Confusion really began with the 3BSD release (a complete system, not an add-on), as it also provided a /usr/ucb/mail command which was just a link to Mail. So, depending on the PATH setting, typing mail could either invoke Unix mail or Berkeley Mail. This remained the same with all Berkeley releases up to 4.3BSD-Tahoe and derivatives; in the end, Unix mail was removed entirely, but the name remained as a link to Mail in all places.

For System V Release 3, a derivative of Berkeley Mail was created: mailx. It remained mostly compatible with Mail, but there were some add-ons and the user interface was slightly changed (Heirloom mailx uses a similar interface if none of the bsd... compatibility variables is set).

This System V mailx command was then also standardized with POSIX.2 in 1992, including many of the extensions.

Linux distributions made the situation even more confusing. They could only use the original Berkeley Mail (System V mailx was closed source until the OpenSolaris release in 2005). Yet because Mail and mailx were sufficiently similar for most applications, it seemed appropriate for many to also feature a mailx command which was just Mail, thus not sufficient for formal POSIX.2 conformance. Most distributions also made mail invoke Mail, since Unix mail was also closed source until January 2002.

To complete the confusion, some commercial Unix vendors dropped support for the original mail over the time and made it invoke mailx.

Heirloom mailx is derived from Berkeley Mail. Since version 10, Heirloom mailx also features independent implementations of the System V and POSIX mailx additions.

Heirloom mailx has previously been developed under the name nail and has been integrated into the Heirloom project in March 2006.

If it is called as Mail, a short shell script should be created which sets the bsdcompat variable before invoking mailx. mail however is an entirely different command and should be taken from the Heirloom Toolchest if an Open Source version is desired.

Portable scripts should either invoke mail without any options or should use the standardized mailx interface. In any case, they should set the MAILRC variable to /dev/null to bypass the user's configuration. As this variable is present in mailx, but not in Mail, using Mail for scripts does not work reliably anyway and should be avoided. (In effect, this means that there is no reliable way to send mail from a script on many BSD derivatives and Linux distributions. But that is a fact one has to live with.)

Gunnar Ritter <gunnarr@acm.org> 2007-01-28

SourceForge.net Logo