What is "mail", and how is it navigated?

The program is located in /usr/bin/mail. Upon execution, Version 8.1.2 01/15/2001 is shown.

Entering list produces:

Commands are:
next, alias, print, type, Type, Print, visual, top, touch, preserve, 
delete, dp, dt, undelete, unset, mail, mbox, pipe, |, more, page, More, 
Page, unread, Unread, !, copy, chdir, cd, save, source, set, shell, 
version, group, write, from, file, folder, folders, ?, z, headers, 
help, =, Reply, Respond, reply, respond, edit, echo, quit, list, xit, 
exit, size, hold, if, else, endif, alternates, ignore, discard, retain, 
saveignore, savediscard, saveretain, core, #, inc, new

Entering ? produces:

Mail Command               Description
-------------------------  --------------------------------------------
t [message list]           type message(s).
n                          goto and type next message.
e [message list]           edit message(s).
f [message list]           give head lines of messages.
d [message list]           delete message(s).
s [message list] <file>    append message(s) to file.
u [message list]           undelete message(s).
R [message list]           reply to message sender(s).
r [message list]           reply to message sender(s) and all recipients.
p [message list]           print message list.
pre [message list]         make messages go back to /var/mail.
m <recipient list>         mail to specific recipient(s).
q                          quit, saving unresolved messages in mbox.
x                          quit, do not remove system mailbox.
h                          print out active message headers.
!                          shell escape.
| [msglist] command        pipe message(s) to shell command.
pi [msglist] command       pipe message(s) to shell command.
cd [directory]             chdir to directory or home if none given
fi <file>                  switch to file (%=system inbox, %user=user's
                           system inbox).  + searches in your folder
                           directory for the file.
set variable[=value]       set Mail variable.

Entering z shows the end of the list of messages – but that command is not presented in the ? help page.

  1. What program is this?
  2. Are there tutorials for its use?
  3. What are some common commands and helpful tricks for its use?
  4. How can the message list be navigated (the opposite of z) or refreshed?

Clarification: This question is about the interactive program and not the script-able command – i.e. the result of typing mail with no flags or parameters into a terminal.

Asked By: cwd

||

As its manual states, mail is:

mail is an intelligent mail processing system which has a command syntax
reminiscent of ed(1) with lines replaced by messages.

That is to say, you could think of it as a quick way to perform some tasks related to the mails you receive in the server you are working on.

The power of mail can be understood when writing shell scripts or cron jobs for example.

To learn it better, I’ve found some articles about mail command:

Another question made on this site deals with the same issue:

Answered By: nozimica

mail isn’t Pine; it’s just mail. In a perfect world, your version of mail should be compatible with POSIX/SUS’s mailx program (The most relevant documentation being under the “Extended Description” heading), but, as usual, determining the deviations from perfection is left as an exercise to the reader.

Answered By: jwodder

This page describes the interactive command in detail, and is in fact a fairly thorough tutorial. Describes commands such as z and z- :

If there is more than a screenful of messages, then z will
show the next screenful, and z- will show the previous screenful.
Answered By: Steve Brown
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.