Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mail(1) — SunOS 1.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

binmail(1)

fmt(1)

newaliases(8)

aliases(5)

sendmail(8)

mailaddr(7)

biff(1)

MAIL(1)  —  User’s Manual — Commands

NAME

mail − send and receive mail

SYNOPSIS

mail [ −f [ name ] ] [ people ... ]

INTRODUCTION

Mail is an intelligent, interactive facility for handling electronic mail.  Mail’s basic unit of information is a message. Mail provides facilities for sending mail to other people, replying to messages you receive from other people, and for browsing through received messages. 

Sending mail.  To send a message to one or more other people, use mail with arguments which are the names of people to send to.  The people arguments can be the names of users on your own system, or they can be network addresses — see below.  Then, type in your message, followed by an EOT (control−D) at the beginning of a line.  The section labelled Replying to or originating mail, describes some features of mail available to help you compose your letter. 

Reading mail.  If you use mail without arguments, it checks your mail out of the post office, and then displays a one-line header of each message found there.  The ‘current message’ is initially the first message (numbered 1); you can display it with the print command (abbreviated p).  You can move among the messages: use the ‘+’ command to move forward a message, the ‘−’ command to move back a message, and simple numbers to address a particular message. 

Disposing of mail.  After examining a message you can delete (d) the message or reply (R) to it.  Deleting a message makes mail forget about it.  If you accidentally delete a message, you do have recourse: you can undelete (u) the message by giving its number, or you can exit (x) the mail session, leaving everything as it was before you started the session.  Messages deleted during the mail session however, usually disappear and are never seen again. 

Specifying messages.  Commands such as print and delete can be given a list of message-numbers as arguments to apply to a number of messages at once.  Numbers in a list are separated by spaces.  Message-numbers are simple numbers, or they can be specified as a range, that is, two numbers separated by a minus sign.  Thus:

delete 1 2
deletes messages 1 and 2, while:

delete 1−5
deletes messages 1 through 5.  The special name ‘∗’ addresses all messages, and ‘$’ addresses the last message; thus the top command (print the first few lines of a message) could be used in:

top ∗
to print the first few lines of all messages.

Replying to or originating mail.  You can use the reply (R) command to respond to mail from someone.  R works somewhat like

%  mail  person
but reply already knows that person is the person who sent you the message you’re replying to:  type in the text of your message, and end the text with an EOT at the beginning of a line.  Note that the reply (R) command is typed as an upper-case command — the lower case r version of reply replies to all persons on a distribution list instead of just the person who sent the message. 

While you are composing a message, you can use ‘escapes’ (usually called ‘tilde escapes’) to get mail to treat such lines in special ways.  For instance, typing ‘~m’ (alone on a line) places a copy of the current message into the response, but shifted right by one tabstop.  Other escapes set up subject fields, add and delete recipients to the message, and allow you to escape to an editor to revise the message or to a shell to run some commands.  These options are described in the summary below. 

Ending a mail processing session.  You end a mail session with the quit (q) command.  Messages which have been examined but not deleted go to your mbox file.  Messages which have been deleted are discarded.  Unexamined messages go back to the post office.  The −f option specifies that mail read in the contents of your mbox (or the specified file) for processing; when you quit mail writes undeleted messages back to this file. 

Personal and systemwide distribution lists.  You can create personal distribution lists so that, for instance, you can send mail to ‘cohorts’ and have it go to a group of people.  Such lists can be defined by placing a line like:

alias cohorts bill ozalp sklower jkf mark cory:kridle

in the file .mailrc in your home directory.  The current list of such aliases can be displayed by the alias (a) command in mail.

System Distribution Lists  System wide distribution lists can be created by editing /usr/lib/aliases, see aliases(5) and sendmail(8); these are kept in a slightly different syntax.  In mail you send, personal aliases are expanded in mail sent to others so that they can reply (lower case r) to the recipients.  System-wide aliases are not expanded when the mail is sent, but any reply returned to the machine will have the system wide alias expanded as all mail goes through sendmail.  If you edit /usr/lib/aliases, you must run the program newaliases(8) to rebuild the aliases database.

Network mail (ARPA, UUCP)  Mail to sites on the ARPA or UUCP network can be sent using name@site for ARPA-net sites or machine!user for UUCP sites, provided appropriate gateways are known to the system.  Be sure to escape the ! in UUCP sites when giving it on a csh command line by preceding it with a \. 

Mail has a number of options which can be set in the .mailrc file to alter its behavior; thus

set askcc
enables the ‘askcc’ (ask for carbon copy) feature.  These options are summarized below in the section labelled Mail Options.

SUMMARY OF MAIL COMMANDS

This summary is adapted from the ‘Mail Reference Manual’. 

Each mail command is typed on a line by itself.  Arguments may follow the command word.  The command word need not be typed in its entirety — the first command which matches the typed prefix is used.  Commands which take message lists as arguments use the next message forward which satisfies the command’s requirements if a message-list is not specified.  If there are no messages forward of the current message, the search proceeds backwards, and if there are no good messages at all, mail types ‘No applicable messages’ and aborts the command. 

−[nnn]
Go to the previous message and print it out.  If the optional numeric argument nnn is specified, go to the nnn’th previous message and print it.

+[nnn]
Go to the next message and print it out.  If the optional numeric argument nnn is specified, go to the nnn’th next message and print it.

?  Print a brief summary of commands. 

!Shell Command
Execute the UNIX Shell Command which follows the !. 

alias (a) With no arguments, print out all currently-defined aliases.  With one argument, print out that alias.  With more than one argument, add the users named in the second and later arguments to the alias named in the first argument. 

chdir [directory]
(c) Change the user’s working directory to the optional directory argument.  Change to the user’s login directory if directory is not specified. 

delete
(d) Takes a list of messages as argument and marks them all as deleted.  Deleted messages are not saved in mbox, nor are they available for most other commands.  Messages deleted in the current mail session can be undeleted with the undelete command described later. 

dp (also dt) Delete the current message and print the next message.  If there is no next message, mail says ‘at EOF.’

edit (e) Takes a list of messages and points the text editor at each one in turn.  On return from the editor, the message is read back in. 

exit (ex or x) Effects an immediate return to the Shell without modifying the user’s system mailbox, the mbox file, or the edit file when using the −f option. 

from (f) Takes a list of messages and prints their message headers. 

headers
(h) List the current range of headers, 20 at a time.  If you want to see another group of headers, you must type a number that lies within that group.  For example,

headers
alone displays the headers of the first 20 messages.  To see headers (say) 41 thru 60, you can type

headers 45
or in fact any number that lies in the range 41 thru 60.  Also see the z command below, which scrolls forwards and backwards through groups of headers. 

help A synonym for ? 

hold (ho, also preserve) Takes a message list and marks each message therein to be saved in the user’s system mailbox instead of in mbox.  Does not override the delete command. 

ignore
takes a list of character strings as arguments.  Lines in the header of mail messages that start with any of the specified character strings are ignored.

mail (m) Takes as arguments login names and distribution group names and sends mail to those people. 

next (n like + or CR) Goes to the next message in sequence and types it.  With an argument list, types the next matching message. 

preserve
A synonym for hold. 

print (p) Takes a message list and types out each message on the user’s terminal.  Typin a print command with a capital P prints even ignored headers. 

quit (q) Terminate the mail session, saving all undeleted, unsaved messages in your mbox file in your login directory, preserving all messages marked with hold or preserve or never referenced in your system mailbox, and removing all other messages from your system mailbox.  If new mail has arrived during the mail session, mail display a message:

You have new mail
If you quit while editing a mailbox file with the −f flag, mail rewrites the edit file.  Mail then returns to the Shell, unless the rewrite of edit file fails, in which case the user can escape with the exit command. 

reply (R) Takes a message list and sends mail to each message author just like the mail command.  The default message must not be deleted.  r (lower case) may be used to reply to all members on a distribution list. 

respond
A synonym for reply. 

save (s) Takes a message list and a filename and appends each message in turn to the end of the file.  The filename in quotes, followed by the line count and character count is echoed on the user’s terminal. 

set (se) With no arguments, prints all variable values.  Otherwise, sets option.  Arguments are of the form:

option=value
or:

option

shell (sh) Invokes an interactive version of the shell. 

size Takes a message list and prints out the size in characters of each message. 

subject
(su) works like the from command but works with subjects instead of message headers. 

top Takes a message list and prints the top few lines of each.  The number of lines printed is controlled by the variable toplines and defaults to five. 

type (t) A synonym for print. 

unalias
Takes a list of names defined by alias commands and discards the remembered groups of users.  The group names no longer have any significance. 

undelete
(u) Takes a message list and marks each one as not being deleted. 

unset Takes a list of option names and discards their remembered values; the inverse of set. 

visual (v) Takes a message list and invokes the display editor on each message. 

write (w) is similar to the save command, but write removes the ‘From’ line and the ‘Status’ line from the header of the messages, whereas save leaves those lines in the message. 

xit (x) A synonym for exit. 

z Scrolls forwards and backwards through groups of headers, 20 at a time.  If a ‘+’ argument is given, the next 20 headers are displayed, and if a ‘−’ argument is given, the previous 20 headers are displayed. 

ESCAPE SEQUENCES

Here is a summary of the tilde escapes, which are used when composing messages to perform special functions.  Tilde escapes are only recognized at the beginning of lines.  The name ‘tilde escape’ is somewhat of a misnomer since the actual escape character can be set by the option escape. 

~!command
Execute the indicated shell command, then return to the message.

~c name ... 
Add the given names to the list of carbon copy recipients.

~d Read the file dead.letter from your home directory into the message. 

~e Invoke the text editor on the message collected so far.  After the editing session is finished, you may continue appending text to the message. 

~f messages
Read the named messages into the message being sent. If no messages are specified, read the current message.  Also see the ~m command which does the same thing but shifts the message right by one tab stop. 

~h Edit the message header fields by typing each one in turn and allowing the user to append text to the end or modify the field by using the current terminal erase and kill characters. 

~m messages
Read the named messages into the message being sent, shifted right one tab.  If no messages are specified, read the current message.

~p Print out the message collected so far, prefaced by the message header fields. 

~q Abort the message being sent, copying the message to dead.letter in your home directory if save is set. 

~r filename
Read the named file into the message.

~s string
Make the named string become the current subject field.

~t name ... 
Add the given names to the direct recipient list.

~v Invoke an alternate editor (defined by the VISUAL option) on the message collected so far.  Usually, the alternate editor is a screen editor.  After you quit the editor, you may resume appending text to the end of your message. 

~w filename
Write the message onto the named file.

~|command
Pipe the message through the command as a filter.  If the command gives no output or terminates abnormally, retain the original text of the message.  The command fmt(1) is often used as command to rejustify the message. 

~~string
Insert the string of text in the message prefaced by a single ~.  If you have changed the escape character, then you should double that character in order to send it.

MAIL OPTIONS

Options are controlled via the set and unset commands.  Options may be either binary, in which case it is only significant to see whether they are set or not, or string, in which case the actual value is of interest.  You can set and unset options during a mail session, or you can place the options in your .mailrc file in your home directory. 

Binary Options.  The binary options include the following:

append
Messages saved in mbox are appended (the default case) to the end rather than prepended.  This is set in /usr/lib/Mail.rc on version 7 systems. 

ask Mail prompts you for the subject of each message you send.  If you respond with simply a newline, no subject field is sent. 

askcc Mail prompts for additional carbon copy recipients at the end of each message.  Responding with a newline indicates your satisfaction with the current list. 

autoprint
The delete command behaves like dp — thus, after deleting a message, the next one is typed automatically. 

ignore
Mail ignores interrupt signals from your terminal and echoes them as @’s. 

metoo
Usually, when a group is expanded that contains the sender, the sender is removed from the expansion.  Setting metoo includes the sender in the group. 

quiet Suppress printing the version of the mail program when first invoked. 

save Saves the message collected prior to an interrupt in the file dead.letter in your home directory on receipt of two interrupts (or after a ~q.) 

String Options.  The following options have string values:

EDITOR
Pathname of the text editor to use in the edit command and ~e escape.  If not defined, then a default editor is used.  The default editor is /usr/ucb/ex.

SHELL Pathname of the shell to use in the !  command and the ~! escape.  A default shell is used if this option is not defined.  The default shell is /bin/csh.

VISUAL
Pathname of the text editor to use in the visual command and ~v escape. 

escape
If defined, the first character of this option gives the character to use in the place of ~ to denote escapes.

record
If defined, gives the pathname of the file used to record all outgoing mail.  If not defined, outgoing mail is not saved.

toplines
If defined, gives the number of lines of a message to be printed out with the top command; normally, the first five lines are printed. 

crt If defined, gives the number of lines of a message to be printed before mail calls up the more(1) utility so that you can peruse the mail messages leisurely.

EXAMPLES

Send mail to Wendy on here system called ariel:

angel%  mail  wendy@ariel
Subject:  New DBX Manuals
The new DBX manual pages are in angel:/usr/man/man1/dbx.1
^D
EOT
angel%

Note that mail asked for a subject — this is controlled by the ask option in the .mailrc file.  There is an example of such a file later on in this section. 

Now when Wendy is working on her system, she will see a mail notification:

work, work, work
You have new mail.
ariel%  mail
Mail version 2.17  12/26/82.  Type ? for help
"/usr/spool/mail/wendy":  1 message 1 new
>N  1  cuthbert  Thu Nov  3 10:03:01  11/265  "New DBX Manual Pages"
&Mail signals its readiness for commands
Carriage-return means read next message
 From cuthbert Thu Nov  3 10:03:01 1983
Date: 3 Nov 83 10:02:56 PST (Thu)
From: cuthbert (Cuthbert Pouncetrifle)
Subject: New DBX Manual Pages
To: wendy
Status: R
 The new DBX manual pages are in angel:/usr/man/man1/dbx.1
 &Mail signals its readiness for commands
Carriage-return means read next message
At EOFMeans there are no more messages
dDelete this message
qQuit from the mail program
ariel%

Here is a .mailrc file in which you can set options to control mail’s behavior:

set crt 30 ask
ignore via apparently-to date from status received message-id

The first line sets the crt option to 30 lines — if there are messages longer than this, mail calls up more to page through the message in 30-line chunks.  The ask option makes mail ask for a subject heading every time you send mail to someone.  Finally, the second line says to ignore any line starting with any of the character strings from the list — this shortns the amount of irrelevant junk that appears at the top of mail messages. 

Here is a line from a .login file (oriented to the C-Shell):

set mail=(10 /usr/spool/mail/$USER)

This set command instructs the C-Shell to look in /usr/spool/mail/$USER for mail every 10 seconds and to notify you if there is mail waiting there.  In the absence of the time specification, the Shell looks every five minutes. 

FILES

/usr/spool/mail/∗post office
~/mboxyour old mail
~/.mailrcfile giving initial mail commands
/tmp/R#temporary for editor escape
/usr/lib/Mail.help∗help files
/usr/lib/Mail.rcsystem initialization file
/bin/mailto do actual mailing
/usr/lib/sendmailpostman

SEE ALSO

binmail(1), fmt(1), newaliases(8), aliases(5), sendmail(8), mailaddr(7), biff(1)
The Mail User’s Guide in the Sun Tutorial for Beginners Manual, which gives an excellent introduction. 
For sendmail installation instructions, see the Sun System Manager’s Manual.

Sun System Release 1.0  —  1 November 1983

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026