GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: mail   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index

3.5.2 Reading Mail

To read messages from a given mailbox, use one of the following ways of invoking mail:

mail

Read messages from your system mailbox.

mail -f
mail --file

Read messages from your mailbox ($HOME/mbox). If the --user option (see below) is also given, read messages from that user’s mbox.

mail -f path_to_mailbox
mail --file path_to_mailbox

Read messages from the specified mailbox.

mail -u user
mail --user=user

Read messages from the system mailbox belonging to user.

Please note, that usual mailbox permissions won’t allow you to use the last variant of invocation, unless you are a super-user. Similarly, the last but one variant is also greatly affected by the permissions the target mailbox has.

Notice that path_to_mailbox is not an argument to --file (-f) option, but rather the first non-optional argument on the command line. Therefore, 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

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 termination of the program. The state is reflected in the header listing and can be changed during the session. The states are:

new

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 mail was exited using the quit command, such messages are moved to the ‘unread’ state. If exit command was used, their state is not changed.

unread

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.

read

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. Read messages in the system mailbox are saved in the ‘mbox’, unless the internal variable ‘hold’ is set. Read messages in ‘mbox’ or in any other mailbox, excepting the system one, will be retained in their current location.

deleted

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’. Upon quitting the program, deleted messages are permanently removed from the mailbox.

preserved

The message has been processed by the preserve (hold) command. When mail quits, such messages are retained in the mailbox.

saved

The message has been processed by one of the following commands: save, write. When mail quits, saved messages will be removed from the mailbox, unless the ‘keepsave’ variable is set. When operating on the system mailbox, messages in this state are deleted, when the quit or file command is used to exit the current mailbox.

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’.

GNU Mailutils Manual (split by node):   Section:   Chapter:FastBack: Programs   Up: mail   FastForward: Libraries   Contents: Table of ContentsIndex: Function Index