|
GNU Mailutils |
General-Purpose Mail Package |
Official GNU Software |
| GNU Mailutils Manual (split by node): | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
? |
To read messages from a given mailbox, use one of the following ways of
invoking mail:
mailTo read messages from your system mailbox.
mail -fmail --fileTo 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_mailboxmail --file path_to_mailboxTo read messages from the specified mailbox.
mail -u usermail --user=userTo 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 reads the contents of user configuration file, if any.
For detailed description of these files, see Personal and System-wide Configuration Files.
After this initial setup, mail displays the first page of header
lines and enters interactive mode. In interactive mode, mail
displays its prompt (‘?’, if not set otherwise) and executes the
commands the user enters.
Following commands quit the program:
Terminates the session. If mail was operating upon user's system
mailbox, then all undeleted and unsaved messages that have been read and
are not marked with hold flag are saved to the user's mbox file
(‘$HOME/mbox’). The messages, marked with delete are removed.
The program exits to the Shell, unless saving the mailbox fails, in
which case user can escape with the exit command.
Program exits to the Shell without modifying the mailbox it operates upon.
Typing EOF (‘C-D’) alone is equivalent to ‘quit’.
Following commands can be used during the session to request online help:
Display detailed command synopsis. If no command is given, help for all available commands is displayed.
Print a list of available commands.
Display program version.
Display program warranty statement.
Move to the first undeleted message.
Move to the last undeleted message.
Move to the next message.
Move to the previous message.
Change to the specified directory. If dir is omitted, $HOME is
assumed.
Read in the contents of the specified mailbox. The current mailbox
is updated as if quit command has been issued.
If mailbox is omitted, the command prints the current mailbox
name followed by the summary information regarding it, e.g.:
|
To control which headers in the message should be displayed, mail
keeps two lists: a retained header list and an ignored
header list. If retained header list is not empty, only the
header fields listed in it are displayed when printing the message.
Otherwise, if ignored header list is not empty, only the headers
not listed in this list are displayed. The uppercase variants
of message-displaying commands can be used to print all the headers.
The following commands modify and display the contents of both lists.
Add header-field-list to the ignored list. When used without arguments, this command prints the contents of ignored list.
Add header-field-list to the retained list. When used without arguments, this command prints the contents of retained list.
Displays the current message number.
Lists the current pageful of headers.
Lists the contents of ‘From’ headers for a given set of messages.
Presents message headers in pagefuls as described for headers
command. When arg is ‘.’, it is generally equivalent to
headers. When arg is omitted or is ‘+’, the next
pageful of headers is displayed. If arg is ‘-’, the
previous pageful of headers is displayed. The latter two forms
of z command may also take a numerical argument meaning the
number of pages to skip before displaying the headers. For
example:
& z +2 |
will skip two pages of messages before displaying the header summary.
Lists the message number and message size in bytes for each message in msglist.
Displays the value of folder variable.
Displays current mailbox summary. E.g.:
|
Prints out the messages from msglist. The variable crt
determines the minimum number of lines the body of the message must
contain in order to be piped through pager command specified
by environment variable PAGER. If crt is set to a numeric
value, this value is taken as the minimum number of lines. Otherwise,
if crt is set without a value then the height of the terminal
screen is used to compute the threshold. The number of lines on
screen is controlled by screen variable.
Like print but also prints out ignored header fields.
Print a multipart message. The decode command decodes and prints
out specified message parts. E.g.
|
Prints the top few lines of each message in msglist. The number
of lines printed is controlled by the variable toplines and
defaults to five.
Pipe the contents of specified messages through shell-command. If
shell-command is empty but the string variable cmd is set,
the value of this variable is used as a command name.
Prints the MIME structure of each message from msglist. Empty msglist means current message.
Example:
|
Tag messages. The tagged messages can be referred to in message list using ‘:t’ notation.
Clear tags from specified messages. To untag all messages tagged so far type
& untag :t |
Marks each message to be held in user's system mailbox. This command
does not override the effect of delete command.
Mark messages as deleted. Upon exiting with quit command these
messages will be deleted from the mailbox. Until the end of current
session the deleted messages can be referred to in message lists using
:d notation.
Clear delete mark from the specified messages.
Deletes the current message and prints the next message. If msglist is specified, deletes all messages from the list and prints the message, immediately following last deleted one.
Takes a message list and a file name and appends each message in turn to
the end of the file. The name of file and number of characters appended
to it is echoed on the terminal. Each saved message is marked for
deletion as if with delete command, unless the variable
keepsave is set.
Like save, but the file to append messages to is named after the
sender of the first message in msglist. For example:
|
i.e., 22 lines (603 characters) have been appended to the file “smith”. If the file does not exist, it is created.
Similar to save, except that only message body (without the
header) is saved.
Similar to Save, except that only message body (without the
header) is saved.
Mark list of messages to be saved in the user's mailbox (‘$HOME/mbox’)
upon exiting via quit command. This is the default action for
all read messages, unless you have variable hold set.
Similar to save, except that saved messages are not marked for
deletion.
Similar to Save, except that saved messages are not marked for
deletion.
These command allow to edit messages in a mailbox. Please note,
that modified messages currently do not replace original ones. i.e.
you have to save them explicitly using your editor's save
command if you do not want the effects of your editing to be lost.
Edits each message in msglist with the editor, specified in
EDITOR environment variable.
Edits each message in msglist with the editor, specified in
VISUAL environment variable.
With no arguments, prints out all currently-defined aliases. With one argument, prints out that alias. With more than one argument, creates a new alias or changes an old one.
Takes a list of names defined by alias commands and discards the remembered groups of users. The alias names no longer have any significance.
The alternates command is useful if you have accounts on several machines. It can be used to inform mail that the listed addresses are really you. When you reply to messages, mail will not send a copy of the message to any of the addresses listed on the alternates list. If the alternates command is given with no argument, the current set of alternate names is displayed.
Switches to compose mode. After composing the message, sends messages to the specified addresses.
For each message in msglist, switches to compose mode and sends the composed message to the sender and all recipients of the message.
Like reply, except that the composed message is sent only to
originators of the specified messages.
Notice, that setting mail variable flipr (see section How to Alter the Behavior of mail) swaps the meanings of the two above commands,
so that reply sends the message to the sender and all
recipients of the message, whereas Reply sends it to
originators only.
Switches to compose mode. After composing, sends the message to the originators and recipients of all messages in msglist.
Similar to followup, but reply message is sent only to
originators of messages in msglist.
To determine the sender of the message mail uses the
list of sender fields (see Controlling Sender Fields). The first field
from this list is looked up in message headers. If it is found
and contains a valid email address, this address is used as
the sender address. If not, the second field is searched and
so on. This process continues until a field is found in the
headers, or the sender field list is exhausted, whichever happens
first.
If the previous step did not determine the sender address, the address from SMTP envelope is used.
Let's illustrate this. Suppose your mailbox contains the following:
|
Now, you issue the following commands:
|
As you see, the value of Reply-To field was taken as the
sender address.
Now, let's try the following command sequence:
# Clear the sender list & nosender # Set new sender list & sender From |
Now, the From address will be taken:
|
Commands sender and nosender are used to manipulate
the contents of the sender field list.
If the command sender is used without arguments, it displays
the contents of the sender field list. If arguments are given,
each argument is appended to the sender field list. For example:
|
Command nosender is used to remove items from the sender
field list:
|
When used without arguments, this command clears the list:
|
The incorporate (inc) command incorporates newly arrived
messages to the displayed list of messages. This is done automatically
before returning to mail command prompt if the variable
autoinc is set.
To run arbitrary shell command from mail command prompt, use
shell (sh) command. If no arguments are specified, the
command starts the user login shell. Otherwise, it uses its first
argument as a file name to execute and all subsequent arguments are
passed as positional parameters to this command. The shell
command can also be spelled as !.
| GNU Mailutils Manual (split by node): | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
? |
Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.