MH & nmh: Email for Users & Programmers

May, 2006

Reading Mail: inc, show, next, prev

With the messages that you and your friend sent, you should have at least five new messages waiting by now. You can't read the messages until you incorporate them from your system mailbox into your account. To do this, type inc at the shell prompt (%). For example:

    % inc
    Incorporating new mail into inbox...

       1+ 01/09 Joe Doe            Here's the first message you asked
       2  01/09 Joe Doe            Another test<<Well, this is another
       3  01/09 To:Joe Doe         What's happening -- did you send the
       4  01/09 To:angelac         A long message<<AWK(1) USER COMMANDS AWK(1)
       5  01/09 To:Joe Doe         Thanks for helping!<<You said that
       6  01/09 Sample MH/MIME me  Sample MIME message for online MH book<<---
    %
    
Okay -- what's all that? Here's an explanation of the output from inc: To read the first message you incorporated, type show and press RETURN. You'll see the current message (in this case, message number 1) on your screen. Your screen will look something like this:
    % show
    (Message inbox:1)
    Return-Path: joed
    Received: by mysun.xyz.edu (5.54/ACS)
            id AA08581; Mon, 09 Jan 1995 16:56:39 EST
    Message-Id: <9501092156.AA08581@mysun.xyz.edu>
    To: angelac
    Subject: Here's the first message you asked for
    Date: Mon, 09 Jan 1995 16:56:37 -0600
    From: "Joe Doe" <joed>

    Hi, Angela!  You asked me to send you a message.  Here it is.
    I hope this is okay and that you can figure out how to use
    that mail system.

    Joe
    
The message header has information (fields such as Received:) that you can usually ignore. Your message may have more, fewer, or other header fields. You can configure show to skip header fields you don't want; see Using mhl.

If the message is longer than one screen, most users just see the first screenful. (What happens depends on your version of UNIX and how your MH package was set up.) Then, until all of the message has been shown, and depending on how your account is set up:

No matter what happens, if your screen pauses before the end of the message, try pressing the space bar or RETURN to get the next screenful of the message. When you've seen the message, you should get another shell prompt (%) on the screen. (In some setups, you may need to type q, for "quit," first.)

Now, to look at the next message, type next at the shell prompt. The display will be just like the one you got with the show command, but you'll see the next message (in this case, message number 2). Message 2 becomes the new current message.

When you're done reading message 2, type prev. This shows the previous message. (For example, if you've just seen message 2, prev will show message 1.)

Because MH commands are used at a shell prompt (%), you can use all the other standard UNIX commands with them, too. For instance, assuming your system's printer command is named lpr, you can print the current message by sending show's output to the printer, like this:

    % show | lpr
    
You can copy the current message to a file with:
    % show > filename
    
and so on -- output redirection works with other MH commands, too.
NOTE: MIME messages are usually difficult to redirect to a file because they may start multiple viewers, print prompts, and so on. A command like cp `mhpath cur` filename will help. The mimecat script decodes a MIME message and can also extract individual parts.

The current message is number 1 again. Let's skip over message 2 and go straight to message 3. Do that by giving the message number to the show command:

    % show 3
    
Use next or show to read all other mail except the MIME message from the automatic server. We'll get to it in Section Using MIME.