Mail programs

You will be required to turn in your assignments by e-mail on lx.cs.niu.edu. Our Linux box provides two mail clients.

The first is nail which is an advanced clone of mail/mailx and both mail and mailx will invoke nail. While nail is considered an excellent batch mode mailer, it not the friendliest mail client if you are composing individual mails.

The supported mail client on our system is mutt. mutt provides both a composition tool and a mail reader.

When composing a message, mutt will use the vi editor unless a different editor is specified in the EDITOR or VISUAL environmental variables.

When reading mail, mutt displays the current content of the incoming mail box or of a local mailbox if specified when invoked.

A comprehensive manual of mutt can be found at http://www.mutt.org/doc/manual/. But the best way to get comfortable with mutt is to use it.

Reading mail

Exercise :

#(Run the following to put mail in your mailbox. Use your actual z-id at z# )

ls | mutt -s lsmail z#
ps | mutt -s psmail z#
who | mutt -s wmail z#
finger | mutt -s fmail z#

#( You should now have at least 4 email messages in your incoming mail box. To view them, invoke mutt with no arguments. )

mutt

#( You should get something like this : )

q:Quit  d:Del  u:Undel  s:Save  m:Mail  r:Reply  g:Group  ?:Help
   1 N F Jun 11 To John Berezin (   5) fingermail
   2   F Jun 11 To John Berezin (   5) fingermail
   3 O F Jun 11 To John Berezin (   1) whomail
   4 O F Jun 11 To John Berezin (   4) psmail
   5 O F Jun 11 To John Berezin (  11) lsmail
   6   F Jun 11 To John Berezin (  11) test















---Mutt: /var/mail/berezin [Msgs:6 New:1 Old:3 4.7K]---(reverse-date/date)-(all)

This is a view of your incoming mail box or the mail box specified

The top line lists a set of single character commands. Under that is a list of messages either waiting for you to fetch from the mail queue. You will also notice one line either highlighted or of a different color. If you were to type one of the commands at the top, it would be applied to the highlighted message.

q - (quit mutt. If you quit mutt, you will be asked if you want to move any read mail to your local mail box. If you answer yes, any messages read, but only those, will be copied into the file mbox in your home directory over and removed from the mail queue. If you answer no, all of your messages will be left in the main queue.

d - will mark the message for deletion. However, the message will not be deleted until you quit mutt and you have confirmed the deletion requests. Once a message is marked as deleted, you cannot use the cursor to move back to it. But if you enter the message number at the left, the cursor will be positioned on that message and you can enter u to undelete the message. Once you have quit mutt, messages cannot be undeleted.

s - will allow you to save a mail message to a topic specific mail box. mutt will attempt to make an educated guess of a mailbox name based on the sender id. You will see an equal preceding the mailbox name. The = tells mutt to use the mailbox file of the specified name in the $HOME/MAIL directory. If the mailbox file does not already exist, it will be created. If it does exist and is correct formatted, the message will be appended to the mailbox file and be marked for deletion. You may specify an alterative filename and if it preceded by the =, it will stored in the specified name in $HOME/MAIL. If you remove the =, the file will be created local to the current working directory.

m - will allow you to compose a new mail message from inside mutt. You will first be prompted for the recipient's email address[es]. You may specify multiple recipients by entering a comma delimited list of email addresses.

r - will reply to currently selected message. r works like m except that it takes the recipient's email address from the current highlighted message.

g - group reply. If the message you received was sent to several recipients at the same time, this command will allow you to reply to all at the same time.

? - quick help. This will list commands available and a short description. Use [space] or [enter] to move down the list. To close the help window, scroll down to the bottom or press [q].

x - exit. This not listed at the top but it is worth knowing. Like q, x exits mutt. However, any changes in message status will not be saved. So, if you marked messages as deleted, this marking will be discarded and the messages will be saved.

If you have any messages in the mail box you are viewing, you will see under the help banner a list of messages.

The left most column of the message list will contain the message number. It is possible to go directly to a specific message by typing its message number.

The next three character columns may hold one or more flags representing information about the message. Flags may be a [space] or one of several letters. N indicates a new message in the mail box. O indicates a message that was listed but not viewed the last time you viewed the mail box. r indicates a message that was no viewed but responded to anyway. If you reply to a message from the menu, its status will be toggled to r. A D indicates a messages that will be deleted when you quit mutt.

Check out the www.mutt.org site and its detailed help for the meaning of other flags. You may even download the manual in several formats.

Next column contains the date of the message.

Next column is the id of the sender.

Next column is the size of the file displayed in parens. If the file has attachments, its size will be counted in the total.

Finally, the sender's id is listed.

If you select a message in the list and press [enter], mutt will display its contents in the bottom half of the screen. mutt uses its own viewer. It is possible to substitute your own viewer such as less, but some of the features such as being able to reply to a message while you are reading it will be lost.

Instead, you may be able to modify or add certain keystrokes to customize the mutt viewer. To do this, create or edit the .muttrc in your $HOME directory according to the help files at www.mutt.org. See www.mutt.org for details.

Here are some basic default navigation commands for the mutt viewer.

[enter] scroll down one line
- scroll up one line.
[space] scroll down one screen.
[ctrl][backspace] scroll up one screen.
q returns back to list of messages.
? will give a list of other key commands.

The same cursor movement available when viewing a message will work when viewing the help screen.

Sending Messages

There are several ways to start creating a mail message.

You can start it in compose mode from the command prompt :

mutt recipient-list

where recipient-list is a single valid email address or a comma delimited list of email addresses.

When mutt starts, it displays the recipient and allow you to edit or add to the list.

Next, it prompts you for a subject. If you leave it blank, mutt allows you either to continue or abort composing a message at this point.

If you choose to continue, mutt invokes an editor for you to use. The default editor should be vi. The choice of editor is set by the evironmental variables EDITOR. You can change the editor by setting the environmental variable EDITOR to your preferred editor. We will discuss variables in a later module.

Use the standard editor commands for the editor invoked. When done, save and quit as usual. At this point you will see a screen that looks like :

y:Send  q:Abort  t:To  c:CC  s:Subj  a:Attach file  d:Descrip  ?:Help
    From: John Berezinski 
      To: John Berezinski 
      Cc:
     Bcc:
 Subject:
Reply-To:
     Fcc: ~/sent
Security: Clear


-- Attachments
- I     1 /tmp/mutt-linux-413u-1000-13286-0  [text/plain, 7bit, us-ascii, 0.1K]





-- Mutt: Compose  [Approx. msg size: 0.1K   Atts: 1]----------------------------
If everything is good, press y to send. If you wish to cancel this message, press q instead. At this point, you will be asked if you would like to postpone this message. If you answer yes, the message will be stored for later retrieval. If you answer no, it will be discarded.

[ If you do postpone a message, you may resume working on it by invoking mutt with the -p option. If you have more than one postponed message, mutt presents a menu similar to a mailbox menu and allows you to select the message of interest. ]

If you have not sent or cancelled the message you may at this point modify most of the fields displayed. Press t to change or add additional recipients. Press c to cc other recipients. Press b to do a blind copy. Press s to add or change the subject line. Press r to change the Reply-To field and f to edit the Fcc field.

If you choose to edit one of these fields, its contents will be displayed at the bottom of the screen and you may use the cursor keys to position the cursor. Type the text you want and/or use backspace to delete characters. When done, press [enter].

It is also possible to attache other files to the message by pressing a at this screen. You may specify a filename or press ? to get a directory listing. The initial directory will be $HOME/Mail and you may have to navigate to the directory where your file attachment is from. When you are in the right place, highlight the file to be attached and press enter. The file can be any type of regular file. You may repeat this for any number of additional files.

When a message is completed, press y to send or q to discard and quit.

A note on Cc vs. Bcc. If you cc (carbon copy) someone, the message indicates that it is not for the person carbon copied. The actual recipient is told who was carbon copied. If you blind carbon copy someone, everything is the same except that the targeted recipient is not told about the carbon copies sent.

You can invoke mutt with additional information on the command line that will skip some or all of the steps above.

mutt -s "subject of mail" recipient-list
mutt -s "subject" recipient-list < file_with_message

If all information is correct in this last command, the editor will not be invoked and the message will be copied directly from file_with_message.

You may also enter compose from inside the mailbox view mode by pressing any one of several character commands.

m, the compose command starts a new message. It first offers you a chance to fetch a postponed message if any exist. It then prompts you for a recipient and a subject. Finally,it invokes the editor.

f, the forward command prompts for a recipient. Next it copies the subject of the currently selected message and allows you to edit it. Finally, it invokes the editor with the a copy of the currently selected message inserted.

r, the reply command displays the recipient of the currently selected message and allows you to edit it or add additional recipients. Next it allows you to edit the subject line. It then asks if you want a copy of the selected message inserted in the message being composed. Finally, it invokes the editor.

Exercise :

Try sending mail to yourself and responding to it in various ways.

A note of interest for viewing received mail :

The displayed sender line of a mail can be counterfeited. To see a more complete listing of the source of a mail message, press h to expand the header. The header is portion of a mail message containing the source and routing stops of the message. It is not normally displayed unless specifically requested. If the starting point in the expanded header does not match the displayed "From:" address, you may want to be suspicious of it, especially if it is asking you for something.

A selection of text editors
Overview