MH Examples

This page shows some random examples of using the MH electronic mail system. Most examples aren't common day-to-day operations like sending and reading mail; instead, they show things that make MH unique and special. If you haven't used MH, and you haven't read the MH history page yet, that page gives some background to help you understand what's going on.

I'll show examples on the Unix command line. If this isn't familiar to you, or if you'd rather use a graphical (GUI) interface to your email, please keep in mind that there are interfaces to MH -- like MH-E and exmh -- that hide the command line from you. Underneath, though, those interface programs are running commands much like the ones I'll show here.

Context
Reading Messages into Other Programs
Great Flexibility
Links: Putting One Message into Many Folders
Annotating and Editing Messages

Context

When you start typical email programs, they give you some kind of "default" view of your messages. For instance, they might start by showing a list of all of your mail folders or a view of the first message in your inbox.

MH is different. It keeps context. Among other things, it remembers your current folder and current message in that folder. It keeps that context until you do something to change it -- like reading another message or looking into another folder.

This means, among other things:

MH also lets you override the context and/or have many contexts. (Simply set, or un-set, the MHCONTEXT environment variable.) For instance, if you want to read another message without changing the current message number, you can use a simple program (like my tcx) that runs an MH command with no context. Or, if you want each of your terminal (shell) windows to be separate from each other, simply give each window its own context.

Reading Messages into Other Programs

Most email programs store email messages in a "folder" which is actually a big file full of many messages. MH is different: it keeps each message in a separate file named 1, 2, 3, and so on. (The filename is the message number.) The files are grouped into Unix directories; each directory is a separate folder.

The mhpath command gives the absolute pathname (the exact location in the filesystem) of a message or folder. This makes it easy to grab an MH message from another (non-MH) program. Because MH also keeps context, you don't even need to know the current message or folder! Here are some example MH commands, typed on a Unix command line:

    $ show
    (Message inbox:23)
       ...Message 23 from the inbox folder appears...

    $ mhpath   (shows pathname of the current folder)
    /home/jpeek/Mail/inbox

    $ mhpath cur   (shows pathname of the current message)
    /home/jpeek/Mail/inbox/23

    $ mhpath last   (shows pathname of the last message)
    /home/jpeek/Mail/inbox/28

So, for instance, the vi text editor has a command :r for reading in a file. You could read the current MH message into vi by typing (with Unix command substitution):

    :r `mhpath cur`

(If the message is MIME-encoded, you may want to use the mhstore command to decode it first.)

Great Flexibility

MH is almost infinitely customizable, so you can make it do a lot of things that other email programs can't. Here's some of why:

Links: Putting One Message into Many Folders

Most email systems make a mail "folder" by putting many email messages into a single file. If you have a lot of mail folders, it can be hard to remember which mail folder has the message you want. One answer is to put a copy of the message in any folder where you might look for it. But that has (at least) two problems: wasted disk space and making all of those copies hard to find if you want to remove the message from your folders.

Because MH keeps each message in a separate file, it's much easier to keep a message in multiple folders. The MH command refile -link "copies" a message into another folder. Even better, it doesn't actually copy the message; it makes a hard link -- a feature of Unix filesystems that lets you keep a file in multiple directories (multiple folders) without taking any extra disk space!

If you ever want to delete those linked messages, cleanup is easy. The Unix command find -inum finds hard links.

Annotating and Editing Messages

An email message has two parts: the header (with lines like From: Joe Doakes <joe@doakes.xyz>) and the body (the text of the message). Most email programs "protect" the header and body from you; they'll only let you change them little, if at all.

MH -- like most Unix programs -- assumes that you know what you're doing. It doesn't put restrictions on you. The messages are in files, and you can edit the header or body any way you want to. Here are some ideas:


More coming... (Suggestions? Please click the link below to send me email.)


[MH Introduction] [Email tips page] [Home page]

Last change: 4 July 2003

Contact Jerry Peek