Thursday, March 01, 2007

Using the UNIX Mail Program

Using the UNIX Mail Program

Contents







Introduction



    The UNIX mail program is a basic e-mail program. It allows the
    sending and receiving of text-only
    e-mail. It is not MIME-compliant, and therefore is not suitable
    for sending binary files such as images,
    word processor documents, or spreadsheets. For such items, use
    the Pine mail program, or one of the
    graphical mail clients such as Netscape 7 or Outlook
    Express 6
    . See Other Mail
    Programs
    for more information.



    For incoming mail, there are commands to read, save, delete,
    and reply to messages. For sending mail,
    you can edit, review, and make other changes to a message as it is
    composed, and then send it to one or
    more individuals, or to a list of people.





Conventions Used in this Document

































    Text style:

    Usage:

    italic

    keywords, glossary entries and text that
    is emphasized.

    bold


    text that is emphasized.

    fixed

    a computer response or prompt as shown on
    screen.

    bold fixed

    commands you type in (commands should be
    typed in lower case-unless otherwise
    indicated).

    italic fixed

    substituting a required variable or
    command.





Sending Mail



    To send e-mail to a person you need to know the person's
    login name and host computer
    system
    . This is known as the person's e-mail address.
    To send mail type:




      Mail login-name@hostname





      Note:To call the UNIX Mail program in the WAM or
      Glue UNIX systems, you must issue the
      Mail command with an uppercase M.
      Using a lowercase m will call a
      different mail program. In the OIT cluster, you may use
      either upper or lowercase.





    Suppose you want to send mail to John Smith whose e-mail
    address is jsmith@wam.umd.edu. At the
    UNIX prompt you would type:




      Mail jsmith@wam.umd.edu


    and press Return. Here, jsmith is the login name
    and wam.umd.edu is the address of
    the host computer, or system, on which John has an account.





    It is not necessary to include the system address if the person
    you are sending mail to has an account
    on the machine from which you are sending mail. If sending mail
    from your WAM account to another WAM
    account holder, you only type:





      Mail jsmith


    and press Return. Otherwise, you need the full e-mail
    address.



    For help in sending mail to an e-mail address that doesn't look
    like an Internet address, contact the
    Help Desk at 301.405.1500 between 8:00 a.m. and 5:00
    p.m. Monday-Friday.



    After you issue the Mail command, the mail program will
    prompt you for the subject of your
    mail. If you wish to include a subject, type it and press
    Return; if you don't want a subject,
    press Return only. The mail program will then prompt you
    with Cc: to send a carbon copy of
    the mail item. If you want to send a copy of the message to
    someone else, enter their login name/address or
    aliases (see Using Mail Aliases) at the
    Cc: prompt. If you do not want to send any
    carbon copies, press Return.



    You are now placed in the mail program's message editor. As you
    type your message, remember to press
    Return at the end of each line.




      Note: If you do not press Return at the
      end of each line, it may appear as though
      the system is inserting Returns but, in fact, this
      is not the case. If you do not press
      Return your keyboard will lock up after 256
      keystrokes, thus preventing you from
      continuing.







Editing Your Message



    If you make mistakes while typing your message and wish to
    correct them, use the Delete (or
    Del) key to erase them. You must make your corrections
    before pressing Return.



    Several functions can be invoked by typing a ~ (tilde)
    followed by an option character at the
    beginning of a blank line:
















      ~?

      gives you a list of the tilde
      escapes that are available.

      ~v or ~e

      ("visual" or "editor") each of
      these options, used at the beginning of a
      line, will invoke editors to
      create, modify, or add to your
      message. Editors make it possible
      to correct lines other than the one you
      are typing, move text, and perform
      other word processing operations that
      aren't possible with the message
      editor in the mail program.



    If you have not customized your EDITOR or VISUAL environment
    variables, on the OIT Cluster you'll get by
    default:
















      ~v

      the vi editor.

      ~e

      the ex editor.




    On WAM and Glue, the default editor for both is
    pico.



    When you finish with your text and are ready to send the mail,
    save the text and exit from the editor
    using the commands appropriate for that editor.



    If you have customized your EDITOR or VISUAL environment
    variables, use the commands appropriate to that
    editor.



    For more information about text editors, see the documents at

    http://www.helpdesk.umd.edu/documentation
    .




      Note: On WAM and Glue, the default
      .environment file contains lines which you can
      uncomment and comment out to change from pico to
      vi.





    If you prefer to use a different editor from the default, you
    can set either ~v or ~e (or
    both) to call that editor. All you have to know is where the
    editor you want to use is located on your
    system. You can find this out by using the UNIX which
    command. For instance, if you wanted to use
    the emacs editor, you could find out where it is by
    typing:




      which emacs


    On Glue, OIT UNIX cluster, or WAM, a pathname is displayed:




      /usr/local/bin/emacs



    You would then use this information to type one of the
    following commands at the UNIX prompt before you
    start the mail program to have either ~e or ~v
    automatically put you into emacs:

















      for ~e:

      setenv EDITOR
      /usr/local/bin/emacs


      for ~v:

      setenv VISUAL
      /usr/local/bin/emacs




    If, instead of typing the setenv command, you place it
    in the appropriate startup file
    (~/.environment on WAM/Glue or appropriate shell
    configuration file of the cluster,
    i.e. .cshrc), your chosen editor will always be available
    using the appropriate ~-option. You
    can also do this by putting one of the following commands in your
    .mailrc file (along with any other
    mailer set commands you think would be useful).














      for ~e:

      set
      EDITOR=/usr/local/bin/emacs



      for ~v:

      set
      VISUAL=/usr/local/bin/emacs





    If you are using one of these special editors, the
    ~-options described in this document (which
    are part of the mail program's message editor) will not work until
    you leave that special editor.

















      ~h

      allows changes to your message
      header (i.e., you can change the
      To: (recipient) and Cc: (carbon
      copy) lists and also change the
      Subject: line).

      ~m message#

      places a mail message you've
      received from someone else into your current
      mail message (Reading your
      messages for a description of a message
      number). The inserted message is
      shifted to the right by a tab - usually
      about 8 spaces. This may make the
      text a bit difficult for the recipient to
      read, since lines that are shifted
      beyond 80 columns will wrap around on
      the reader's screen, looking like
      this:




      Here is your note accompanying the forwarded message
      And here is the forwarded message, which is in-
      dented
      8 spaces and then wraps around into the empty
      area
      where the indentation is, making it hard to read




    An alternative approach is to save the message you want to
    forward, and put it into a file using the
    s command (see Saving Mail Messages).
    When you write to the person to whom you
    wish to forward the message, you can place it in the e-mail with
    the ~r option (see below), which
    doesn't indent it. For clarity, it also helps to use a separator
    to indicate where your mail ends and the
    appended message begins:



    -------------- forwarded message

































      ~r filename


      reads all contents of the file
      known as filename into your current
      message following the line you
      just typed before the ~r.

      ~s new-subject


      changes the subject line to
      new-subject (it can be more than one word).

      ~t users

      adds users to the To: list
      (the list of people receiving your
      message); users can be any
      combination of login-name@mailaddresses and
      aliases (see Using
      Mail Aliases
      ).

      ~w filename

      writes (saves) your message to the
      file known as filename.


      For example,



      ~w bob.feb12


      would save the current message to
      a file called bob.feb12.

      ~! command

      executes a UNIX command, but does
      not put the output in your mail message.

      ~~


      includes a single tilde as the
      first character of a line.





Sending Your Message



    Once the message has been entered and is ready to be mailed (be
    sure to exit any editors you may have
    called with ~e or ~v), there are two ways by which
    to send the mail and then exit the mail
    program. In either case, first press Return to place the
    cursor on a blank line. Then, either press
    Ctrl-d (hold down the Ctrl (Control) key and type
    d), or type a period (.) in
    column 1 and press Return.






Aborting Your Message



    If you decide that you want to quit the mail program without
    sending your message, press Ctrl-c
    twice. This command can not be issued while you are in an editor.
    After pressing Ctrl-c the first time,
    the mail program will prompt you to confirm that you wish to exit
    without sending your message. The message
    will be saved in a file named dead.letter in your home
    directory. This is useful if you decide to send
    the mail message later. If you abort another mail message, the
    mail program overwrites the previous contents
    of the dead.letter file; so, if you wish to keep the
    contents of the first file, you should either
    rename it or move
    it to another directory.






Sending Mail



    While using the mail program to read mail messages, you can
    also send a mail message. Refer to
    Other Mail Commands, for details.





Receiving and Reading Mail




    If there are mail messages waiting for you when you log in to
    your UNIX account, you will see
    the message:




      You have mail




    On the OIT cluster, you are automatically placed into the mail
    program. On other machines, enter the
    program by typing:





      Mail


    at the system prompt followed by pressing Return. A "new
    mail has arrived" message appears (if you
    received new mail while reading mail already in your mailbox).



    When you first start the mail program, it tells you how many
    messages are waiting and then displays the
    header information for each message. The header information lists
    the mail address of the sender, the date
    and time the message was sent, the number of lines and characters
    in the message, and as much of the
    message's subject line as will fit on the screen.



    The illustration in the next section indicates what a typical
    UNIX mail account would display indicating
    three new (N) mail messages and one old mail message which
    was unread (U).



    After the header information for the messages has been
    displayed, you can read or issue mail commands at
    the mail program prompt (&).



    Some systems use the ">" symbol at the beginning of a line
    which indicates this particular message is
    the default message (i.e., the message that will be manipulated if
    you do not specify a particular message
    number). This message is the one referred to in the explanations
    below as the "current message".





Reading Your Messages



    To read a particular mail message, type the number of that
    message at the mail prompt (&) and
    press Return. For instance, to read the message from
    akins@umd5.umd.edu below, type 2

    at the & prompt and press Return:




      & 2





        Mail $Revision: 4.2.4.2 $  Type ? for help..  Type ? for
        help. "/usr/spool/mail/userid":4 messages 3 new

        U 1 jdoe@umd5.umd.edu Tue Aug 27 11:56 12/4182
        >N 2 akins@umd5.umd.edu Wed Aug 28 09:12 13/33 "Good
        N 3 johndoe Wed Aug 28 13:40 16/360
        N 4 johndoe Thu Aug 29 10:14 82/1697 "lunch today?"

        &




    The mail message will be displayed on your screen. If the
    message is more than one screen long, the
    program will display a single screenful at a time. A -MORE-
    message will appear at the bottom of the
    screen to tell you that additional information exists. To view the
    rest of the message, press the space
    bar
    . Refer to the Using Set Commands section
    in this document for information on
    scrolling through text that appears on your screen.






Message List



    If after reading any one mail item you wish to see the list of
    messages again, type h at the
    & prompt and press Return.






Replying to a Mail Message



    To respond to an e-mail message that you have received, use one
    of mail's two reply commands r or
    R. Both commands are issued by typing the command followed
    by the number of the e-mail message to
    which you wish to reply. For example:





      & r 2




    would reply to message number two. If a reply command is issued
    without a message number, a reply is
    generated for the current message.















      r

      reply is sent to the original
      sender and all other recipients of the
      original mail message.


      R

      reply is sent to the original
      sender only, not other recipients.



    The above commands differ only in who will receive the reply
    message. Remember the difference between
    the two reply commands. For example, if you are replying to a mail
    message sent by your professor to the
    entire class, you might prefer that only the professor receive
    your reply. Since the r and R

    commands are system dependant, the roles can change.





Cleaning Up Old Mail



    If you read your mail and take no further action, then when you
    exit from the mail program all of your
    messages will remain in your system mail file. The next time you
    read mail, the old messages will appear
    with any new mail you receive.



    You should save whatever mail you want to keep and make sure
    that all mail is deleted as soon as
    possible. On most systems, mail is held in a common area, and one
    person's accumulation of large volumes of
    mail potentially jeopardizes the ability of others to get mail.
    (On WAM and Glue, on the other hand, mail
    storage space comes out of your own personal quota, which you can
    handle in whatever manner is convenient for
    you.)



    The mail program's keepsave setting determines whether
    mail that you save elsewhere is
    automatically deleted or not. Some systems at the University have
    keepsave set to retain mail after
    you save it; others have it unset to delete such mail. You can
    check this with the set command, and,
    if you prefer, change it.






Saving Mail Messages



    To save a mail message in a file, you must issue the save
    command (s), followed by the numbers of
    the messages you wish to save and the name of the file you wish to
    save them in. There is no standard
    file-you must give a file name.




      & s message_list filename





    When using the save command, the message_list can
    specify several message numbers, a single
    message number, a range of numbers, or no message number. If you
    do not specify a message number, the
    "current" message is saved to the file. For example, to save two
    messages (numbers 3 and
    4) in a file named johnmail, type:




      & s 3 4 johnmail






Deleting Mail Messages



    Once you have read and/or saved a message, it is important to
    remember to delete it (if it is still
    there). The delete (d) command is used for this purpose.
    Simply type the delete command followed by
    the message numbers of the messages you wish to delete.




      & d message_list




    For example:





      & d 3 4




    This will delete messages 3 and 4 (which you
    saved previously in a file named
    johnmail). A range of numbers can be deleted by using a
    hyphen. To delete messages
    1 through 20 you would type the command as
    follows:




      & d 1-20






Undeleting Mail Messages



    There is an undelete (u) command that you can use to
    reactivate messages which have been
    deleted; however the undelete command only works if you have not
    yet exited the mail program. After exiting
    the mail program, any messages that have been deleted cannot be
    retrieved.






Exiting the Mail Program



    There are two ways to exit the mail program:




      Type q and press Return. This exits the
      mail program and removes any deleted or
      saved messages so that the next time you read your mail,
      the deleted and saved messages will not
      appear.



      Type x and press Return. This exits the
      mail program but does not remove any
      deleted or saved messages. All messages will show up when
      you next call up the mail program.







Other Mail Commands



    There are many other commands you can use to manipulate your
    mail messages. Some of the most useful mail
    commands are briefly described in this section.



    In the following descriptions, a message_list may
    consist of a single mail message number, a list
    of message numbers separated by spaces, a range of message numbers
    whose numbers are separated by a hyphen
    (e.g., 2-4), or a combination of any of these. For
    example:




      d 3


      d 3 5 6


      d 3-5


      d 3-5 7 10-14




    If a message_list is not given, the mail program uses
    the current message.



    A user_list consists only of user names and mail
    addresses separated by spaces, such as:




      m jdoe@wam.umd.edu
      carol@umd5.umd.edu











































































      Command

      Explanation

      ?

      displays a list of some of the
      mail commands.

      ! command

      executes a UNIX command then
      returns to the mail program.

      d msg. #

      deletes the # message.

      e message_list

      edits listed messages with the
      EDITOR text editor (see Editing
      Your Message
      ).

      h

      displays header information for
      the twenty most recent active mail
      messages.

      m user_list

      sends a mail message to the listed
      users (this works the same as sending
      mail from the command line).

      n

      displays the next message.


      q

      exits the mail program and removes
      any deleted or saved messages. The next
      time you read mail, the deleted
      and saved messages will not appear.

      r msg. #


      replies to the message numbered #.
      The subject line is the same as the
      original message #, but a "Re:"
      will be prefixed to show that it is a
      reply. Reply is sent to the
      original sender and all other recipients of
      the original message.

      R msg. #

      sends a reply only to the original
      sender. This is similar to the r
      msg command.


      Note: The r and R commands act
      as described above on some systems (WAM
      and the UNIX cluster), and the
      opposite way on others (Glue-where you can
      set the replyall setting, not
      available on most other systems, to reverse
      their meaning if you wish-see Using Set Commands). It is
      a good idea to do a man
      mail
      command on your system to make sure
      you know how these two commands
      behave.


      s msg.# filename

      saves the numbered message to a
      file.

      u message_list

      undeletes listed message(s).


      Note: The undelete command only
      restores messages if you have not yet
      quit the mail program. If you have
      quit the mail program, deleted messages
      cannot be restored.


      v message_list


      edits listed messages with the
      VISUAL text editor.

      x or ex


      exits the mail program, but does
      not remove deleted or saved messages from
      the mail file.





Customizing Your Mail Environment



    The UNIX mail program allows you to customize your mail
    environment to make it easier to send and
    receive mail. These commands can be issued from the mail prompt
    (&) or made automatic by placing
    them in a file named .mailrc in your home directory.






Using Mail Aliases



    The mail program provides a timesaving feature called
    alias. Aliases are abbreviated names that
    represent the mail address of a single user or several users. They
    allow you to send mail to a group of
    people quickly without requiring you to remember all of their
    individual mail addresses, or to a single
    user with a long or difficult-to-remember address. The
    alias command is used to define aliases. For
    example, a simple alias could look like:





      alias rob rob@wam.umd.edu




    and a group alias could look like:




      alias class rob@umd5.umd.edu mark
      sue@wam.umd.edu




    The latter would create an alias named class that
    consists of the three class members listed. A
    group alias can consist of actual addresses, aliases or a
    combination of both. If you use the alias
    command to define an alias while in the mail program, it will
    exist until you exit the mail program; if
    you put the alias command in your .mailrc file, it
    will be available every time you send
    mail.



    To use a mail alias after you create it, substitute the alias
    name for the login name and mail address
    you would normally provide when sending mail. For example:




      Mail class




    sends mail to all the users listed under the alias class
    in the .mailrc file.



    If you have more names in your alias list than will fit on one
    80-column line, you have three
    options:




    1. Keep typing without pressing Return, allowing
      the text to wrap around from line to
      line. You can do this for up to 255 characters-a little
      over 3 lines-but it is sloppy.
    2. Type the list on several lines, but end each line with
      a \ (backslash) and press Return
      (the word alias only goes on the first line).
    3. Make aliases for subsets of your list, and then make a
      final alias consisting of a list of
      these "sub-aliases".





Using Set Commands



    Many mail program options can be set with the mail program
    set command. These options can be
    used temporarily by issuing the set command while using the
    mail program, or permanently by placing
    the desired set commands in your .mailrc. The
    default system options for the mail program
    are set in the file /etc/mail/Mail.rc for WAM/Glue and
    /usr/share/lib/Mail.rc on the
    cluster. You can set additional options, or unset system defaults
    with the unset command, in your
    .mailrc.



    Set command options are either binary or valued.
    Binary set options are either set or not
    set (on or off), there is no value associated with them; valued
    set options are set to a particular
    value. Binary options can be set simply by using the set
    command and the option name.




      set option




    For example:





      set keepsave




    Binary options can be unset by using the unset command
    and the option name. For example:




      unset askcc





    Valued options are set using the set command with a
    slightly different format.




      set option=value




    For example:




      set crt=24




    would signal the mail program that you are working within a 24
    line screen and it will pause every
    screenful of text accordingly.



    Several options can be set on a single line, such as:




      set append dot ask hold askcc
      crt=24




    You can see a list of the binary options that are on/set and
    value options that have a value by simply
    typing:





      set




    Some of the more useful set options are briefly described
    below. Valued set options are indicated
    as such, all other options are binary.







































































      Set option

      Function

      ask

      prompts you for a subject whenever
      you mail a message.

      askcc

      prompts you for a carbon copy list
      whenever you mail a message.


      crt

      tells the mail program how many
      lines long your terminal screen is so that
      mail messages are displayed
      appropriately. The system default is 24
      lines. (crt is a valued
      option.)


      dot

      allows you to use a .
      (period) alone on a line to send your message
      and quit the mail program.


      EDITOR

      specifies the text editor to
      invoke when the ~e or e commands
      are used to edit a mail message.
      EDITOR is a valued option. Remember to
      specify the full pathname.


      On WAM and the OIT cluster, the
      paths for the emacs and vi

      editors are:




        /usr/local/bin/emacs


        /usr/ucb/vi




      hold

      messages that have been read but
      not deleted or saved are left in your
      system mail file.

      keepsave

      messages that have been saved to a
      file and are left in your system mail
      file instead of being deleted.

      metoo

      allows you to receive a copy of
      the message.


      noheader

      header information for messages in
      your system mail file is not displayed
      when you start the mail program.

      record

      specifies the name of a file to
      which all outgoing mail messages are
      appended (record is a valued
      option).

      replyall


      (Glue and Sun workstations)
      reverse the meaning of R and r to
      be like other systems in which
      r replies to all recipients and
      R replies to author.

      save

      aborted messages are saved in the
      dead.letter file.

      VISUAL

      specifies what text editor is
      invoked when the ~v or v

      commands are used to edit a mail
      message. VISUAL is a valued
      option. Remember to give the full
      path name of the editor as mentioned
      previously in the EDITOR
      description above.





Forwarding Your Mail to Another Computer



    If you have accounts on several computer systems, and you would
    like to be able to read your e-mail on
    only one system, you can forward your mail from your UNIX account
    to another computer system. To do this,
    simply create a file named .forward in your home directory
    that contains your e-mail address on the
    other system. For example, if you have a UNIX cluster account and
    a WAM account, and you wish to forward all
    your mail to the WAM system, use a text editor to create a
    .forward file on the cluster that contains
    the line:




      your-loginname@wam.umd.edu




    As long as the .forward file exists on the cluster, all
    mail sent there will be forwarded to the
    WAM system. To stop mail forwarding, simply delete or rename the
    .forward file.




      Note: If you wish to forward mail from your WAM
      or Glue account to your cluster account,
      you must place the .forward file in your mail
      directory.






Other Mail Programs




    The standard UNIX Berkeley mail program described here
    is only one of many mail programs. Other
    easier to use mail programs with more or better features are
    available. Most of the publicly available UNIX
    systems at the University have mailers available.



    One example is the Pine mail program. Pine is the
    more popular of the mail programs because
    it can be used from any kind of computer. It has many advanced
    features including a graphical interface for
    reading mail, a help utility, and the ability to "attach" files to
    mail messages. To use it, type
    pine at the UNIX prompt.



    Another example is the mail-handler (mh) system. The
    mh system is a group of independent
    programs that are called separately from the Unix prompt to
    perform mail handling functions - sending mail,
    or retrieving, reading, saving, replying to and forwarding
    incoming mail. The mh mail handler has
    facilities to set up aliases and can send blind carbon copies to
    others within the mail program. Each mail
    item is maintained as an individual file and can be placed in a
    folder (directory) of choice.



    Graphical mail clients, such as Netscape 7 or Outlook
    Express 6
    , are a convenient way to check your
    e-mail, and are the preferred alternative to
    Berkeley mail and Pine. See
    http://www.helpdesk.umd.edu/documents/0/690
    for more
    information about which client would work best for
    you.







Getting Help


0 comments:

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More