Полезная информация


UNIX Unleashed, System Administrator's Edition

- 24 -

Mail Administration

By Jeff Smith and Chris Byers

So, they've gone and made you postmaster, have they? Perhaps you're approaching this new job with a little trepidation--and you should. Electronic mail administration is one of the most complex system administration tasks and one of the most visible. If you break an obscure program that few people use, your mistake may go unnoticed. If you break the mail system, all the users on your system are affected, and most people consider electronic mail to be one of UNIX's most valuable services. Even worse, if your site is connected to the Internet, your mistakes may be visible at remote sites, and those sites' postmasters will not hesitate to inform you that, while your mother may love you, they consider you and your broken mail system to be little better than pond scum. (Those are the moderates--others may not be so kind.)

Still with me? Good. Despite the potential for making mistakes on a grand scale, mail administration at many sites is routine. You probably won't have to fuss with the e-mail system much once you manage to get it up and running, and this chapter helps you do just that. First, you get a broad overview of how e-mail works, an explanation of some of the terminology you'll see in this and other books, and pointers on where to get more information. Finally, you'll see a step-by-step example of how to set up the sendmail program and its configuration file, sendmail.cf.

What this chapter won't do is cover complex configurations like a multiprotocol mail hub that routes mail from the Internet to UUCP or a DECnet network. You won't learn how to set up the Domain Name System (DNS), although a properly working DNS is essential to the e-mail system. This is covered in Chapter 20, "Networking."

UUCP will be covered in more detail in Chapter 26, "UUCP Administration," but we touch on it here to show how it relates to e-mail. Finally, this chapter won't make you into a sendmail guru, but if you're lucky, you'll never need to be one.

Overview & Terminology: E-mail from Point A to Point B

An electronic mail message begins its life as a file on your computer's disk, created by a Mail User Agent (MUA). After you compose the letter, the MUA gives it to a mail router like sendmail. The mail router gives it to a Mail Transport Agent (MTA). The message traverses one or more hosts and networks and is given to a final delivery agent, which appends it to the recipient's mailbox, another disk file. Each of these terms is explained in detail later in this chapter.

An MUA is just a fancy name for a mail-reading and -sending program, such as the SVR4 mailx. Other examples of MUAs are elm and the Rand corporation's Mail Handler (MH) programs. An MUA is the only part of the mail system with which users usually interact, since a good MUA hides the complexity of the rest of the system from them (but not from the postmaster)!

A mail router is a program that takes a piece of mail and decides where it should go and how to get it there. For instance, depending on the recipient, a letter might need to travel over a TCP/IP network using the Simple Mail Transfer Protocol (SMTP), or via a dial-up connection using the UNIX to UNIX Copy (UUCP) protocol, or even to an office fax machine. The mail router uses the recipient address and its own internal configuration information to decide the best MTA, and then hands the letter to the MTA.

An MTA is a transport program that understands the e-mail protocols of a particular network and can transport a letter over that network. For instance, the UUCP transport agents understand UUCP protocols but know nothing about SMTP. If the mail router were to mistakenly route an SMTP letter to a UUCP transport agent, it wouldn't know how to deliver it.

The final delivery agent does nothing but take a mail message and append it to the recipient's mailbox, following whatever local conventions are used to separate messages within a mailbox. The program /bin/mail is the usual final delivery agent on SVR4 systems.

In real life, the distinctions between MTAs and MUAs and mail routers are sometimes blurred. For instance, sendmail, although primarily a mail router, can also function as an MTA because it understands the SMTP protocol and can transport mail over a TCP/IP network. Therefore, in Figure 24.1 the separate functions of mail router and MTA are really a single program. Further, the SMTP-server part of the remote end of the MTA is often another sendmail program, which may do additional routing and forwarding of the mail before it reaches its final delivery agent. Some MUAs even do their own mail routing, and some, like MH, can be configured to speak SMTP, an MTA function. Despite this real-world blurring of function, the conceptual framework outlined above is a good one to keep in mind.

The Different Mail Front-Ends (MUA's)

Although there are only a few MTA's available for transferring mail across the Internet, there are a number of MUA's available for use. I will go into some detail about each of the more commonly used MUA's and discuss some of their advantages and disadvantages in this section.

The more widely used mail user agents are mail, elm, and pine, and each have their own personalities and quirks (much like system administrators).

A Look at mail

The original flavor of a mail front end was the rather fiendishly cryptic (though very useful and effective) UNIX mail utility.

Even though one always ran the risk of accidentally deleting a mail message (which always came in handy as a good excuse for "missing" a message), it was still a reliable and effective MUA and is still in wide use today by many UNIX users and administrators.

In general, mail allows you to browse, display, save, delete, and respond to messages. When you send a message, mail lets you edit and review messages being composed and lets you include text from files or other messages.

Setting Up Mail for Users

The incoming mail for each user is stored in the system mailbox. This is a file named after the user in /var/spool/mail (on AT&T flavors of UNIX). mail looks in this file for incoming messages, but by manipulating the mail environment variable you can have it look in a different file, which you define. At the time you read a message, it is marked to be moved to a secondary file for storage. This file is then called mbox and is put in your home directory. Like the incoming mail location, mbox can also be changed by setting the MBOX environment variable. All messages remain in the mbox file until they are manually removed.

Mail Commands and Switches

Mail comes with a large number of switches and configuration settings to allow for highly customized use. These options are as follows:

-d Start debugging output.
-e See if there is any mail present. If there isn't, it returns nothing to the screen and gives a successful return code.
-F Put the message in a file whose name is that of the first recipient. This also overrides the record variable, if it is set.
-H Print only the header.
-I Ignore interrupts (can also be set with the ignore variable).
-n Don't initialize mail from the system default Mail.rc file.
-N Don't print header.
-U Convert uucp addresses to Internet standard addresses. This option overrides the environment variable conv.
-v This passes the -v flag to the sendmail utility.
-f [filename] Tells it to read messages from filename instead of the system mailbox. If there is no filename specified, it reads messages from mbox.
-f [folder] Use the file folder in folder directory (this is the same as the folder command). The name of the directory is listed in the folder variable.
-h [number] This is the number of network "hops" made to this point. This is provided so that infinite delivery loops do not occur. This is also related to the TTL, or time to live for a mail message packet.
-r [address] Pass the address to the MTA or network delivery software. It is important to note that all tilde (~) commands are invalid in this option.
-s [subject] Make the Subject header field as subject.
-T [file] This option prints the contents of the article-id fields of all messages on file. This is used for network news programs such as pointcast, etc.
-u [user] This options allows you to read a specific user's mailbox. This only works of you have the correct permissions to that user's home directory.

On starting mail, a system-wide file is read for commands. This file is /usr/lib/Mail.rc. These commands are read to initialize certain variables, after which it reads from the private start-up file of the user who started the mail utility. This file is called .mailrc, and it is normally placed in the user's home directory. It can, however, be placed and accessed elsewhere by modifying the MAILRC environment variable for your personal commands and variable settings.

The .mailrc file is usually used for setting up initial display options and lists of aliases. You store your initial commands here when you start up mail. The following commands, however, are not valid in this file: !, Copy, edit, followup, Followup, hold, mail, preserve, reply, Reply, replyall, replysender, shell, and visual. Also, if there is an error in that file, the remaining lines are ignored.

By using a template .mailrc file, you can easily standardize each user's mail interface with very little difficulty. All you have to do (obviously) is copy that template into the users' home directories, and (if necessary) do some minor editing for each user's particular needs.

You can send a message directly to another user or users by including names of recipients on the command line. If no recipients appear on the mail command line, mail enters command mode, where you can read messages sent to you. If you don't have any messages, it simply sends the message to standard output no mail for username and then exits the mail utility.

While you are in command mode (that is, while reading messages), you can also send messages.

When you are composing a message to send, mail is in input mode. If you don't specify a subject as an argument to the command, mail queries you for a subject. After you enter a subject, mail enters input mode, at which point you can start writing the body of the message you want to send.

While you're typing the message, mail stores it in a temporary file. This temporary file is used for reviewing or modifying the message. By using the appropriate tilde escape sequences (~:) at the beginning of an input line, you can modify the message text.

After you are in the body of your text, enter a dot (EOF) on a line by itself to actually send the message. At this point, mail submits the message to sendmail for routing to each recipient.

The recipients can be a local username or usernames, an internet address (name@domain), a uucp address of the form [host!...host!]host!username, filenames for which you have write permission, or alias groups. If the name of the recipient begins with a pipe symbol (|), the remainder of the name is taken as a shell through which the message is piped. This can be used with any program that reads standard input, such as lpr, to record outgoing mail on a printout.

An alias group is simply the name of a list of recipients that is set by the alias command. The alias command takes the names from the /etc/aliases file, or it can be taken from the Network Information Service (NIS) aliases domain.

While you are composing messages to send, the following tilde escape commands can be used. They all must appear at the start of the input line. The escape character (~) can be changed by setting a new value for the escape variable. The escape character can be entered as text by typing it twice.

~! [shell-command] This lets you escape to the shell. If a shell command is entered, it is then run.
~. This simulates EOF (terminate mail message input and send message)
~: mail-command


~_ mail-command
These allow you to perform the indicated command. You can only use them when sending a message while reading a mail message.
~? This prints a summary of the tilde escapes.
~A This inserts the autograph string Sign into the current message.
~a This inserts the autograph string sign into the message.
~b name ... This adds the names to the blind carbon copy (Bcc) list. This command is similar to the carbon copy (Cc) list, but the names in the Bcc list are not shown the message header.
~c name ... This adds the names to the carbon copy (Cc) list (and these names show up in the message header).
~d This command lets you read in the dead.letter file. This file's name is listed in the variable DEAD, which can be modified.
~e This command invokes the editor to edit the message. The default editor is ex. This is defined in the EDITOR variable.

TIP: Using the ex editor is a real pain. If you are used to using the vi editor, change the EDITOR variable to vi.
-f [message-list] This command lets you forward the listed messages or the current message being read. This only works when sending a message while you are reading mail. The messages are inserted without being altered.
~h This command prompts you for the message header lines: Subject, To, From, Cc and Bcc. To edit the header lines, simply backspace over it and retype.
~i [variable] This lets you insert the value of the named variable into the message.
~m [message-list] This command lets you insert text from the specified messages or the current message into the letter. This is only valid if you are sending a message while reading mail. The text message gets shifted to the right, and whatever string is contained in the indentprefix variable gets inserted as the leftmost characters of each line.
~p This prints the message being entered.
~q This gets you out of the input mode. If you were entering a message and did not save it, whatever you entered to that point is saved in the dead.letter file.
~r filename


~< filename


~<! Shell-command
These commands let you read in the text from the specified file or the standard output of the specified shell-command.
~s subject This sets the subject line to subject.
~t name Add each name to the list of recipients. This is similar to setting up a distribution list.
~v This command invokes the visual editor to edit the message. The particular editor that it uses is listed in the VISUAL variable, and the default is the vi editor.
~w filename This writes the message text into the specified filename, minus the header.
~x This exits the message the same as ~q, but it does not save the message in the dead.letter file.
~| shell-command This pipes the body of the message through the given shell command. If the shell command exits successfully, the command output replaces the message.

Reading Your Mail

The first thing you see when you enter the command mode (immediately after running the mail command) is a header summary of the first several messages, followed by a prompt for one of the commands listed below. By default, the prompt is an ampersand (&).

Each message has a reference number in front of it. The current message is marked by a > in the header summary. The commands that take an optional list of messages should be used with the reference number; if no number is given, the current message is affected.

The message-list is simply a list of message specification, separated by space characters (space delimited), which can include the following:

. Specifies the current message.
n Denotes the message number n
^ Specifies the first undeleted message.
$ Specifies the last message.
+ Specifies the last message.
- Specifies the previous undeleted message.
* Specifies all messages.
n-m Specifies an inclusive range of message numbers.
User Specifies all the messages from user.
/string Specifies all the messages with string in the subject line (upper and lower case is ignored).
:c This specifies all messages of type c. c can be one of the following:
d deleted messages
n new messages
o old messages
r read messages
u unread messages

Mail Commands

If you are in command mode and you just hit enter with no arguments, mail assumes that you want to print the messages and starts printing to the default printer (if one is defined). The complete list of commands is as follows:

! shell-command

This command escapes you to the shell command. The shell to which you escape (Bourne, Korn, etc.) is defined in the SHELL variable.

# comments

This can be used or placing comments in your command, just as you would place comments in you .mailrc file. You must have a blank space between the # sign and the start of your comments.


This lets you print the current message number.


This will show you a summary of commands (for people like me with poor memories).

alias [alias recipient...]


group [alias recipient] This declares an alias for the given list of recipients. In much the same way as distributions lists work in other mail readers, mail will be sent to the entire alias (or group) specified. These aliases can be defined in the .mailrc file. To get a listing of the defined aliases, simply type in the command "alias" by itself.

alternates name...

This command lets you declare a list of alternate names for your login. When responding to a message, mail will not be sent to these names. If no arguments are supplied, this will show a current list of alternate names.

cd [directory]


chdir [directory]

This command allows you to change the current directory. Just as within the Korn or Bourne shell, cd without an argument uses the environment variable $HOME as the directory.

copy [message-list][filename]

This command copies messages to the filename without marking the messages as saved. All other functions are equivalent to the save command.

Copy [message-list]

This saves the specified messages in a file whose name is derived from the authors user name, also without marking the message as saved. This is otherwise equivalent to the Save command.

delete [message-list]

This deletes messages from the system mailbox.If the autoprint variable is set to on, it also prints the next message following the last message that was deleted.

discard [header-field...]


ignore [header-field...]

These commands will suppress the printing of the specified header fields when displaying messages on the screen, such as "Status" and "Received". By default, unless the variable alwaysignore is set, all header fields are included in the saved message. This does not apply to the Type or Print commands.

dp [message-list]


dt [message-list]

These commands are equivalent to the delete command followed by the print command, as they first deletes the specified messages from the system mailbox and prints the following one.

edit [message-list]

This command edits the given messages. Each of the messages are put in a temporary file and the EDITOR variable is used to the name of the editor (preferably vi). The default editor is ex.




These commands will exit you from the system mailbox without any changes. If you use this command, you will not save any messages in mbox.

file [filename]
folder [filename]

These commands quit you out of the current malbox file and read in the named mailbox file. There are certain special characters used as filenames, such as:

% The current user's mailbox.
& Read previously read messages from your mbox.
+filename A filename in a specified folder directory. The folder directory is also listed in the folder variable.

If no arguments are used, file simply shows the name of the current mail file, as well as the number of characters and messages it contains.


This command only prints the name of each mail file in the folder directory.

followup [message]

This commands responds to a message and records the response in a file. The name of this file is derived from the author of the message. This command also overrides the record variable if it is set.

from [message-list]

This shows the header information for the indicated message or current message.


This prints a summary of all commands.

hold [message-list]


preserve [message-list]

These commands hold the specified messages in the system mailbox.

if s|r|t

This is a conditional execution, used primarily in the .mailrc file. The command will execute up to an elseif or an endif. If s is used, the command will run if the program is in send mode; if r is chosen, the command executes only if in receive mode; if t is chosen, the command is run only if mail is run from a terminal.

load [message] filename

This command will let you load the specified message from the name file. This allows you to load a single saved message from filename, including headers.

mail recipient

This command sends a message to the specified recipient.

Unread [message-list]

This marks each message in a message list as having been read.


This exits the mail command. It also saves the messages that were read in the mbox file and keeps the unread messages in the system mailbox.

reply [message-list]


respond [message-list]


replysender [message-list]

These commands allow you to send a response to the author of each message in messasge-list.

Reply [message]


Respond [message]


replyall [message]

These commands let you reply to the specified message, sending a response to each recipient of that message. If the replyall variable is set, the replyall command always sends the reply to all recipients of the message.

save [message-list] [filename]

This command will save the specified message in the specified filename. If the filename does not exist, it is created. If no filename is specified, the file named in the MBOX variable is used (mbox by default). Once the message is saved it is deleted from the system mailbox unless the keepsave variable is set.

set [variable[=value]]

This lets you define a variable and assign a value to it. You must use an = sign between the variable name and the value (with no spaces).


This invokes the shell as defined in the SHELL variable.

source filename

This let you read commands from the given file name and return to the command mode.

undelete [message-list]

This restores deleted messages. It only works on messages deleted in the current mail session.

unset variable ...

This will undefine a specified variable or variables. This will not work on imported variables such as environment variables from the shell.


This will scroll the header display either forward (+) or backward (-) by one screen.

Forwarding Your Messages

In order to forward a message you must include it in a message to the recipients with the ~f or ~m tilde escapes. You can define a list of recipients in a file in your home directory to forward mail to automatically called .forward. The list must be comma separated and the address must be valid or the messages will bounce without any warnings.

Defining Variables

Mail behavior is defined by a set of variables in your .mailrc file. The necessary environment variables are as follows:


This is the user's home directory.


This is the name of the initial mailbox file to read. By default it is set to /var/spool/mail/username.


This is the name of each user's personal start-up file, which is $HOME/.mailrc by default.

These variables cannot be modified from within mail. They must be set before you begin a mail session.

The specific mail variable for each user is set in the .mailrc file in each user's home directory. The following are all of the mail variables that can be altered either in the .mailrc file or by using the set (or unset) command:


For all network names whose login name components match, treat them as identical. The default is noallnet.


This tells mail to always ignore the header fields, not just during print or type. This will affect the save, Save, copy, Copy, top, pipe, and write commands, as well as the ~m and ~f tilde escapes.


This will append messages to the end of the mbox file when you exit instead of prepending them. By default this is set as noappend.


This will prompt you for the Cc list after you enter a message. The default is noaskcc.


This will ask you for a subject. This is enabled by default.


This will automatically print messages after the delete or undelete commands are run. By default this is set to noautoprint.


This enables use of the exclamation point or "bang" as a shell escape command, such as in the vi editor.


This will set the default command for the pipe command. This has no default value.


This variable converts UUCP addresses to the address style you specify. The style can be one of the following:


Use this if you are using a mail delivery program that conforms to the RFC232 standard for electronic mail addressing.


This will remove loops in the UUCP address path, which are usually generated by the reply command. There is no rerouting performed since mail doesn't know anything about UUCP routes or connections.

Conversion is disabled by default.


This will pipe the messages which contain more than number lines through the command which is specified by the PAGER variable. This is the more command by default.


You can specify the name of the file where a partial letter is saved in case of an interrupted session. By default this is defined as the dead.letter file in the user's home directory.


This will turn on the verbose diagnostics for debugging. The default setting is nodebug.


This will read a dot on a line by itself as an EOF marker. By default this is set as nodot, but dot is set in the global startup file.


This enables you to edit the headers as well as the body of the message when you use the ~e and ~v commands.


This defines the editor (or command) to run when you use the edit or ~e command. By default this is set to ex.


This will substitute c for the tilde (~) escape character.


This is the defined directory for saving standard mail files. If the user specifies a file name beginning with a plus (+), the file name is expanded with the directory name preceding it.


This prints the header when you enter mail. This is enabled by default.


This keeps all read messages in the system mailbox instead of moving them to mbox. The default is nohold.


This will tell it to ignore interrupts while entering messages. The default is noignore.


By default, string is set the TAB key. It is used to mark indented lines from messages included with ~m.


This is set by default to the ls command; used to list the files in the folder directory.


This sets the file name where messages are saved after being read. The default is $HOME/mbox.


This can be used in a local area network (no router between machines). Normally, when several recipients are sent mail, their addresses are forced to be relative to the originating author's machine, which allows ease of response from the recipients. This flag greatly reduces traffic "over the wire."


This locates the files used to save the outgoing messages. The default is nooutfolder.


This will insert a form feed after each message sent through a pipe. nopage is the default.


This is used for paginating the messages on the screen. By default it is set to more, but pg can also be used.


This will allow you to set the prompt in command mode. By default it's set to &.


This will enter mail without the opening message being displayed. This is disabled by default.


This will record all outgoing mail in filename. This is disabled by default.


This will have the opposite the effect of the reply and Reply commands.


If this is set on, the mail message will be saved to the dead.letter file if it is interrupted on delivery. Set on as default.


This will define how many lines you can have for headers. This is used by the headers command.


This allows the background mailer to finish before returning to command mode. The default setting is nosendwait.


This will define the preferred shell you use when you escape to a shell. By default it is set to sh. It will first go to the inherited shell from the environment.


If the ~a (autograph) command is given, includes the autograph text in the message. There is no default.


This tells the top command how many lines of the header to print. This is set to 5 by default.


This will invoke sendmail with the -v flag.


This points to the preferred visual screen editor, which is vi by default.

So much for the .mailrc settings. If you have the mail utility installed on your server or workstation, take a look at the .mailrc file to get a feel for how the file is put together.

A related file is the /usr/lib/Mail.rc file. This is the global startup file, which was referred to earlier in this section. This sets up the initial settings for the mail utility for each user, and it contains most of the default variables that are included with the initial .mailrc file.

A look at elm

At this point, you may be wondering, why go into so much detail about an outdated utility? Well, for one thing, most of the newer and easier to use MUAs are based on the old original mail utility, and much of the same functionality has been added to them and enhanced. Also, this is a good way to illustrate why you would want to move to another utility such as pine or elm.

In this section, I'll take a look at elm, followed by pine in the next section, since these are the most popular text-based MUAs in use today.

The biggest difference between elm and mail is that elm uses a screen-oriented interface, as opposed to the command line interface used by mail. It is also a great deal more intuitive to use, as well as being highly tunable for mail administrators. As with mail, elm will also run on virtually every flavor of UNIX without any modifications.

Elm is also 100 percent compliant with the RFC-822 electronic mail header protocol guide, which means that it will comply with all existing mail standards. In terms of reliability, it has been in use for many years by tens of thousands of sites with no problems.

The Main Menu of elm

Upon looking at the main menu, which appears after opening elm, you will see the first line (showing the name of the current folder, the number of messages in the folder and the current version of elm), the list of messages and a paragraph at the bottom showing the available one-letter commands.

In the list of messages, the inverse video bar will indicate the currently active message. The status field is the first field on the screen, and it can be blank or it can have a combination of characters, where the first character has a temporary status and the second has a permanent status. The characters are: E for an expired message, N for a new message, O for an old message, D for a deleted message, U for urgent mail, A for messages that have an action associated with them, and F for a form letter. There may also be a "+" in the third field which would indicate a tagged message.

In the next field, each message is numbered, which can come in handy for quickly opening a specific message.

The third field from the left indicates the date that the message was sent, in the format MMM, DD.

The fourth field from the left shows who sent the message. By default, elm tries to display the full name of the person who sent the message, but if this is unavailable, it will show either the login name and address of the person who sent it or just the sender's login name.

The fifth field in the list shows the number of lines in the message. And, finally, the sixth field shows the subject of the message (if one is included).

Elm will show ten or more messages at one time, depending on the screen settings. To read a mail message, simply highlight the one you want to read and hit enter.

The functions available from the main screen are as follows:

<return> or <space>--This will read the current message.

|--This allows you to pipe the message to a system command, such as lp.

!--This escapes to the shell.

$--This will resynchronize the folder.

?--This puts you into help mode; any key pressed will be explained.

+ or <right>--This will put you into the next page of messages.

- or <left>--This will put you into the previous page of messages.

=--This will set the current message number to 1.

*--Make the current message number equal to the last one.

<number><return>--This will set the message number of the highlighted message.

/--This starts a pattern search in the subject/from lines.

//--This starts a pattern search for the entire folder.

<--This will let you search for specific calendar entiries.

>>--This is the same as `s' for saving a message.

a--This will put you into the alias mode.

b--This will bounce (or remail) a message. This is related to the forward command.

C--This will copy the current message or all of the tagged messages to the folder.

c--This changes the current folder to another elm folder.

d--This will delete the current message.

<ctrl>-D--This will delete all messages matching a user-supplied pattern.

e--This will edit the current folder.

f--This let you forward a message to a specific user. The only difference between this and bounce is that a bounced message will show as being sent from the original sender, where a forwarded message is designated as being sent from the person who forwarded it.

g--This will let you do a group reply to everyone who received the current message.

h--This will disable the headers in messages.

J--This moves the current message to the next one in line.

j or <down>--This will move you to the next message that is not marked as deleted.

K--This will move you up the list to the previous message.

k or <up>--This will move you up the list to the previous message if it is not marked as deleted.

<ctrl>-L--This will refresh the screen.

m--This will send mail to arbitrary users.

n--This lets you read the current message then go to the next undeleted message in the list.

o--This will let you go into the options menu, where you can change the mail system options interactively.

p--This lets you print the current message, or all of the tagged messages.

Q--This known as the quick quit, since it quits without prompting the user.

r--This lets you reply to the author of the current message.

s--This is the command to save the current message to the folder.

t--This tags the highlighted message for later manipulation.

<ctrl>-T--This will allow you to tag all of the messages matching a specified pattern.

u--This will undelete only the current message.

<ctrl>-U--This allows you to undelete all messages which match a specified pattern.

x--This is the exit command, and it will prompt you for saving messages, etc.

X--This will exit immediately, without prompting.

Luckily, most of these commands are listed at the bottom of the main menu, so you don't have to memorize them (unlike the mail utility).

You can also send a file (or attachment) on the command line to a specific user if it will save you time. You can do this by typing the following command:

elm -s "message subject" recipient<filename

The configuration file is called elmrc in the user's home directory. Use this to define specific settings as needed for the special needs of your users.

Debugging the elm mailer

How many times have you heard this from your users; "Where's my mail? I lost my saved messages!"? Elm has a few debugging tools to help you track down some of the more common problems.

In the first menu screen you can use the h, or headers command, to show all of the header information that might be sorted out with weeding settings. This might help to see if the address field got buggered somewhere along the line.

The @ command can also be somewhat helpful. It simply shows a screen of debugging information for each message, such as the number of lines and offsets.

The # command will actually show the entire record structure for the current message to see if the message format is corrupted somehow.

To see the full return address of the current message, the % command can be used. Like the h command, this is useful to see if the address got corrupted or mislabeled.

You can also start elm with the -d option, which starts the debugger. This will create a file in the user's home directory called ELM:debug.info, which will give a good deal of debugging information useful for tracking down problems.

If you use the debugging option, you might need to get the AT&T System V Interface Definition Reference Manual to look up the error names that get reported.

Inclusion in Xwindows

Most Xwindows interfaces give you an option to include a post office in the user's setup. This can be done somewhat easily by modifying the Xwindows configuration file and adding that specific mailer.

As an example, on HP-UX systems, these modifications take place in the user's $HOME/.vue/mwmrc file. In this file, you can specify that a mailbox be present and which mailer you want to use. This is elm by default in HP-UX. See your system's specific Xwindows guide for more details.

The pine mailer

Line elm, pine is a text-based full screen mail utility (MUA). It has a few more features than elm, and is probably more widely used than it as well.

Pine was developed by a few unix gurus at the University of Washington to act as a simple e-mail front end for their users on campus. Because of its ease of use for novice users as well as its stability and configurability, it was quickly adopted first by other Universities and then by a large number of Internet Service Providers as their default mail interface.

Pine can get and send mail from almost any mail format because it uses the c-client library to access mail files, which can act as a switch between different mail formats and drivers. If used with IMAP (Interactive Mail Access Protocol), you can have an IMAP server, like imapd, running on a central host, letting users access their mail without actually having to log onto the central host. (See RFC1176 for more on IMAP).

Mail can be handed off to either sendmail (as is usually the case) or it can be sent using SMTP. This and other configuration settings will be covered later in this section (see RFC822 for more details on SMTP).

MIME is also supported in pine for moving multipart and multimedia e-mail. MIME stands for Multipurpose Internet Mail Extensions (defined in RFC-1341). By using this, any received MIME message gets saved to files, whatever their format. This also allows users to attach files to their messages, such as GIF files, which can be detached and displayed (if running X-terminal).

On starting up pine, you can give it the following options:

-d debug-level

This sets debugging a debugging level (0 means off) and sends the output to the .pinedebugX file in the user's home directory.

-f folder

This opens a named folder in place of the default INBOX.

-i keystrokes

This is like a startup script, where the keystrokes, separated with commas, run on startup. By default, pine starts up in the FOLDER INDEX screen if no keystrokes are specified.


This tells it to use the function keys for commands.


This expands the folder list.

-n message-number

The specified message number will be opened immediately.

-p config-file

Let's use the defined configuration file. By default, this is the .pinerc file.

-P config-file

This will make it use the specified configuration file instead of the global configuration file pine.conf.


This puts you into the restricted demo mode, where you can only send mail to yourself.

-sort order

This tells it to sort the display of the index by arrival, subject, from, date, size, or reverse order. By default, the arrival order is chosen.


This will enable the interrupt command ^Z so that a user can suspend pine.


This will send mail directly to the given address and drop you into the message composer on startup.


This displays the help files for pine.


This will print on the screen a fresh copy of the system pine configuration file (not to be confused with the .pinerc file).

Each of these options is shown at the bottom of the screen when you use pine. As a very easy-to-use mail front end, it is easily the most popular one in use.

Configuring Pine

As I mentioned before, pine has a configuration file for all users called .pinerc located in each home directory. The following shows this file and how to configure it.

The variables are:


This will override the full name defined in the /etc/passwd.


This will set the domain name for the sender's "From:" field.


This is left blank if you are using sendmail as your MTA. You define your list of SMTP servers here.


This will set the news-collections for news reading, as well as defining the NNTP server used for posting news.


This will define the path of the local or remote INBOX, such as $HOME/INBOX or {mail.domain}inbox.


This will list all the incoming message folders.


This is similar to a path statement, as it lists the directories where saved message folders may be found.


This is only needed if the NNTP server name is not set or news is located on a different server.


This will override the default path where the sent-mail folder is kept.


This will override the default path where the postponed messages are located.


This will define where the read messages are to be moved when you quit pine.


This will define where the signature file is located. The default for pine is $HOME/.signature.


This will define the path for a shared or global address book, if one is used.


This specifies the path for the personal address book. By default, this is the $HOME/.addressbook file.


This will define a set of features (shown in the setup/options menu). This will set defaults such as select-without-confirm, and so on. By default, each is prepended with the no- option.


This allows a list of one letter commands to be executed on startup.


This will cause it to display these headers when composing messages.


When composing a message, this will add customized headers to the message.


This will determine the default name for save folders.


This will specify the default name for Fcc.


This will set the order of presentation of messages in the index.


This sets the order of presentation for address book entries.


This is set to the screen settings of the window or screen you are using. By default this number is set to US_ASCII.


This will specify the program used in the Composer.


This sets the program that will be called to view images.


This will strip the hostname used in the From: field if the user-domain is not set.


This lets you select your printer.


This is used if special print drivers are needed for a nonstandard printer.


This is set by pine to control the beginning-of-month pruning for sent mail.


This is also set by pine for displaying the new version of pine.

UUCP as an MTA

There is an alternative to sendmail that has been around for many years, although it isn't purely a mail transfer agent. UUCP (UNIX to UNIX Copy) can act as an MTA as well. In fact, one could make the argument that it was the original MTA, since it was used to copy text files used