GNU Mailutils |
|
General-Purpose Mail Package |
Official GNU Software |
The mail
utility operates on three kinds of mailboxes. The
user system mailbox is the mailbox where the incoming mail for
the user is stored. Its location is system-dependent and is
determined using the common mailutils rules (see mailbox statement). The personal mailbox (or mbox, for short) is
the default location for saving messages that have been read. By
default it is $HOME/mbox or whatever file specified by the
MBOX
environment variable. Any other mailboxes are called
secondary mailboxes.
When called without arguments, mail
opens the system mailbox
for the invoking user. The --file (-f) used without
arguments instructs mail
to operate on the personal mailbox
instead. When this option and a single command line argument are used
together, mail
treats the argument as the pathname of the
secondary mailbox to operate upon.
Notice that this argument is not an argument to the --file (-f) option itself, but rather the first non-optional argument on the command line. This means that any number of additional options are allowed between the --file option and the mailbox file name. For example, the following three invocations are equivalent:
$ mail -fin mymbox $ mail -f mymbox -in $ mail --file -in mymbox $ mail --file -i mymbox -n
Additionally, for conformance to the GNU standards, the following form is also accepted:
$ mail --file=mymbox -i -n
The --user (-u) option allows the system administrator to assume another user identity for operating on this user’s mailboxes. Obviously, it is available only to system administrators. For example:
mail --user=tom
reads mail from the system mailbox of the user ‘tom’, and
mail --user=tom --file
reads mail from the personal mailbox of this user.
Unless you have started mail with --norc command line option,
it will read the contents of the system-wide configuration file.
Then it will read the contents of user configuration file, if it exists.
For detailed description of these files, see Mail Configuration Files.
After this initial setup, mail
displays the first page of header
lines (unless the -N option has been given), followed by a prompt,
indicating that it is waiting for regular commands. Upon receiving a
command, mail
parses and executes it, displays the result on
the screen, prints the prompt and waits for the next command. This
process is continued until mail
receives any of the commands
‘quit’, ‘exit’ or the end-of-file character (ASCII 4, or
C-D).
Each message in the mailbox has a state that affects how it is retained or deleted upon closing the mailbox when terminating the program (see the quit command) or when switching to another mailbox (see the file command). The state is reflected in the header listing and can be changed during the session. The states are:
The message is present in the system mailbox and has not been read
by the user or moved to any other state. When mail
terminates, messages in this state are retained in the system
mailbox. If the mailbox is closed, such messages are moved to the
‘unread’ state.
The message has been present in the system mailbox for more than one
invocation of mail
and has not been read by the user or
moved to any other state. When mail
terminates, messages in
this state are retained in the system mailbox.
The message has been read by the user, i.e. processed by one of the
following commands: copy
, mbox
, next
,
pipe
, prev
, print
, Print
, struct
,
top
, type
, Type
, undelete
, or any of the
following escapes (in message compose mode): ~f
, ~m
,
~F
, ~M
.
When mail
terminates, messages in this state are handled
depending on the mailbox they are in.
If mail
was operating on the user system mailbox, all
messages in state ‘read’ are preserved. The location where
they are preserved is determined by the hold
variable
(see Mail Variables). If it is not set (the default), the
messages are moved to the user’s mbox. If hold
is set,
the messages are held in the system mailbox instead.
The ‘read’ messages in any other mailbox will be retained in their current location.
The message has been processed by one of the following commands: ‘delete’, ‘dp’, ‘dt’. Messages in this state are ignored by any command, excepting ‘undelete’, which changes their state back to ‘read’. When closing the mailbox, deleted messages are permanently removed from the mailbox.
The message has been processed by the preserve
(hold
)
command. When closing the mailbox, such messages are retained in
the mailbox.
The message has been processed by one of the following commands:
save
, write
. When mail
terminates, messages
in this state are handled depending on the mailbox they are in.
If mail
was operating on the user system mailbox, the
default behavior for ‘saved’ messages is to remove them
from the system mailbox. If, however, the keepsave
variable
is set, they are preserved using the same rules as for ‘read’
messages (see above).
Saved messages in non-system mailboxes are retained in their current location.
Unless the mailbox is empty, exactly one of its messages will be marked as current message. Upon startup, current message is set to the first new message, if there is any, or the first unread message if there is any, or to the first message in the mailbox. In the header listing, current message is marked with the ‘>’ sign at the beginning of the line. Current message is changed by any of the following commands: ‘dp’, ‘prev’, ‘next’.
This document was generated on January 2, 2022 using makeinfo.
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.