Previous Table of Contents Next


You can use mailx to send mail to users on remote systems. These systems must be connected via a direct wire, a modem, or a LAN. If you are connected to remote systems, you can use the uucp address format or the Internet (Arpanet) format, depending on your site's setup. For information on how your system is connected to other systems, contact your system administrator. You can use mailx to send the system administrator mail by typing mailx root.

If you have a uucp connection to other systems, you can use the following address format:

     mailx host!name

where host is the name of the system and name is the name of the user you wish to send the message. This format is for a system directly linked to your system. To send to a system via "hops" (using other systems to get to the destination) you must specify each system in the path. For example,

     mailx mitek1!mitek3!mitek5!nancy

would send the message to the mitek1 system, which would forward the message to the mitek3 system. The mitek3 system would forward the message to the mitek5 system, which would deliver the message to the user nancy.

If you are connected to the ARPANET or you have the network MAP for uucp, you can use the format:

     mailx nancy@mitek5

to send the same message to the same user on mitek5. This is a much shorter and more convenient form of a remote address. But it does require a map of all systems you wish to send a message.

For further information on using remote mail at your site, contact your system administrator.


The mailx command provides a way to organize your mail. The feature is called folders. This feature allows you to save messages in a certain directory. Within this directory you can save messages to files based on the names of recipients, senders, or subjects.

There are a few preliminary steps you have to take before you can use the folder feature. The first step is to create a subdirectory in your HOME directory for storing mail items. For example,

      mkdir mail

changes your working directory to $HOME and then creates a directory named mail. The next step is to edit your .profile file and add the following two lines.

      export folder

This sets the shell environment variable folder to mail. Since the path of the directory does not begin with a slash (/), the directory is assumed to be in your HOME directory. You must re-execute your .profile for this new variable to take effect or log out and log back in to the system. By setting this variable you can use the +filename feature on the shell command line when you invoke mailx. When you use a plus (+) before a filename mailx knows to place the message list in the directory defined by the folder variable. To re-execute your .profile type . ./.profile and press Return. Next, edit your .mailrc file. Add the following line.

      set folder=mail

This allows you to use a plus (+) inside mailx to have messages saved to files in the $HOME/mail directory.

Placing messages in folders

You can relate a file to a folder. Each folder in the folder directory contains a set of messages. You can use any of the mailx commands that have filenames as arguments to store messages to a folder file. For example,


saves the current message to a file with the name of the sender.

Multiple folders

Once you have established different files for various types of messages you can use the folder command inside mailx to manipulate the messages stored within these different files. For example,

     folder MBOX

sets the current mailbox to MBOX. Thus all subsequent commands are based on the assumption that MBOX is your new mail file (folder). From the shell command line you can use the -f option to have a certain file be the mailbox. This allows you to use the mailx commands on the messages stored in the specified file. For example,

     mailx -f MBOX

causes the same setup as the internal folder MBOX command.


Because mailx is so complex, you may have some difficulties getting it to function exactly like you think it should. One suggestion: locate a mailx guru and buy the person off. It will be cheaper and much less frustrating. In perspective to other application type programs that exist in the world, mailx is not really that difficult to learn. It does have a few bugs worth mentioning though.

It currently does not support the full Internet addressing scheme. Someday when there is a stable standard for Internet it will do this.

If a line in the message only contains a . (period), there is a very high possibility that the entire message will not be delivered to a remote host. The period signifies "end of message" on the old mail program. The old mail program is the standard delivery program.


Refer to the ed, ex, ls, pg, and vi commands described in modules 39, 43, 84, 103, and 151.

You may wish to read about the biff (BSD), notify (SV4.0), and vacation commands in the User's Reference Manual which came with your system.


The following list of files are used or updated by the mailx command.

$HOME/.mailrc Your personal customization file read by mailx at startup.
$HOME/mbox Your secondary mailbox for story messages.
/usr/mail/ The post office directory, where each user's mailbox is stored (SV).
/usr/spool/mail The post office directory (BSD).
/usr/lib/mailx/* The files containing the help messages (SV).
/usr/lib/mailx/mailx.rc The default customization file read by mailx at startup. Used by all users on the system (SV).
/tmp/R[emqsx]* Temporary files used for various mailx requirements.


The mailx command can be invoked with the -e option to only return a return code. If you have mail in your mailbox, mailx returns a 0 (zero); otherwise, mailx returns a nonzero value.

Previous Table of Contents Next