$book = '..'?>
include "$book/mh.php"; includeHeader('hea.html', 'cosemime.html'); ?>If you use the quit command at a What now? prompt, it leaves the draft message for you to work on later.
MH also has a very useful feature called draft folders that lets you keep many draft messages, work on them, and send them "in the background" while you do something else. This section explains how to work with draft messages in MH. (If you have nmh, your mh-draft(1) manual page has a summary.)
If you started using MH from scratch, your account probably uses just a single draft message. (It has to be set up especially to use an MH draft folder instead of the draft message.) A "single draft message" means that whenever you start to send a message with comp, repl, forw, or dist, the draft is always written to a file named draft in your MH directory. If you start one of those programs and the draft file already exists, you'll see this message:
Draft '/yourMHdir/draft' exists; disposition?Press RETURN for a list of what you can do. Here are the choices:
You can also get here directly and skip the disposition? prompt by starting with the command:
% comp -useThat's the normal way to re-edit an existing draft message.
NOTE: If you're re-editing a draft that you started with repl, forw, or dist and its -annotate switch, the original message won't be annotated. That's because there's no way for MH to find the original message number just by looking at the leftover draft. You can annotate the message yourself with anno.
Instead of using a single draft file, you can set up an MH folder that holds many drafts. This has some great advantages:
What now? pushto send your messages, you don't have to wait to start a new message until the previous draft has been sent. This is because push doesn't process the draft right away -- it takes a few seconds, especially on a busy computer. Without a draft folder, with only one draft file, the draft exists until it's been sent. A draft folder avoids this problem by letting push take its time sending a draft while you work on a new draft.
To set up a draft folder, you may want to skip ahead and read about folders. Once you've set up a draft folder, though, you don't need to think about folders much. Here's how you do it:
% folder -push +drafts Folder /yourMHdir/drafts doesn't exist; create? y drafts+ has no messages. % folder -pop [previousfolder+ now current.]
Draft-folder: drafts
What now? q whatnow: draft left on /yourMHdir/drafts/1That shows that the draft message is number 1. Then start another draft (with comp or repl or...). Instead of the old prompt:
Draft '/yourMHdir/draft' exists; disposition?MH will give you a fresh draft. Then, if you type quit again, you'll see that this new draft has the next higher message number in the draft folder:
What now? q whatnow: draft left on /yourMHdir/drafts/2How do you finish a draft that you've left in the draft folder? An easy way is with the following command:
% comp -use nwhere n is the draft message number that you want to resume. Easier: if you want to re-edit the draft you started most recently, that draft should still be the current message in the draft folder... in which case you can omit the message number n.
If you're not sure which message you want, you can scan the draft folder to get a summary of your draft messages:
% scan +draftsOr, the recomp shell script is probably the easiest way of all.
As explained in the Section Single Draft Messages, if you're re-editing a draft that you started with repl, forw, or dist and its -annotate switch, the original message won't be annotated.
After you send a draft, MH renames it with a leading comma (,) or hash mark (#). For instance, without a draft folder, your draft file could be renamed ,draft. In a draft folder, draft number 3 would be "deleted" by changing its name to ,3. If you need to recover a draft message, just rename it without the comma or hash mark. The techniques are in the Section Removing and Recovering Messages.
If you type quit -delete at a What now? prompt -- or, if your editor program returns a nonzero exit status to whatnow (see the Section Aborted Draft Messages) -- whatnow will delete your draft as explained above. When that happened, versions of MH before 6.7.2 just said that the draft was "deleted." MH 6.7.2 changed the message to a user-friendly:
whatnow: problems with edit -- draft left in /yourMHdir/drafts/,2
Here's one editing feature that isn't user-friendly. Some editors return a nonzero exit status when the file they were editing is perfectly fine. (Versions of vi from AT&T and Sun have this "feature.") whatnow will think that the editor failed -- and delete your draft.
If you use an editor like that, find out whether your version of MH was built with the [ATTVIBUG] configuration option. If you can't use [ATTVIBUG], you can make a shell script like the one below, myvi, that edits the draft and always returns a zero exit status. (You can also get the script from this book's online archive. It's at examples/mh/bin/myvi.)
Example: Workaround for vi editor problem:
myvi
#! /bin/sh # myvi - workaround for "vi" that returns non-zero exit status # and makes MH "whatnow" delete draft message. # Usage (in MH profile) Editor: myvi vi $* exit 0To install myvi, see the Section Writing Shell Scripts for MH and the Section Changing Default Editors. The Section Writing Your Own Draft Message Editor(s) explains more about writing draft editors.
When you type q at a What now? prompt, it leaves the draft message without sending it. If you have a draft folder, the command line you'd type to recompose the draft is long. Also, it can be hard to remember the draft number -- so you have to scan the draft folder, then remember to change your folder back.
The recomp script helps with that. If you give it a message number in the draft folder, it starts comp -use on that message with your favorite editor program. Without a message number, recomp scans the draft folder, then lets you enter the number of the message you want to recompose, and then starts comp -use. When you exit your editor, you get the usual What now? prompt.
Another section shows how to set up recomp.
The scandrafts script is nice when you're wondering what's in your draft folder or you need to work in it.
$ scandrafts -stay Draft message(s) you've already sent: ,1:Subject: Re: SC or GA islands ,5:Subject: Re: our previous message about banners dialups ,6:Subject: Re: Can you help? ,7:Subject: Out this morning To get them back, use 'mv'. =========================================================== Draft message(s) you haven't sent: 1 03/07*To:alison@mvus.cs Project status<<Alison, the scan: message 2: empty 3+ 03/07*To:kx9cq@cornell. Scientific Visualization Dem You'll be in a /bin/ksh shell in the +drafts folder To quit, type control-d. scandrafts> rmm 2 scandrafts> mv ,6 6 scandrafts> scan 1 03/07*To:alison@mvus.cs Project status<<Alison, the p 3+ 03/07*To:kx9cq@cornell. Scientific Visualization Demo 6 03/04*To:"Warren Z. Von Re: Can you help?<<Warren, yo scandrafts> refile 6 +outbox scandrafts> CTRL-D [folder +inbox now current] $First, you see four messages that have already been sent. The send program put commas at the beginnings of their names. Next come the messages that haven't been sent. One draft is empty (this can happen if you have trouble composing a message).
Then, because the -stay switch was used, scandrafts starts the default shell (this person uses the Korn shell). The shell prompt is set to scandrafts>. The current folder and current directory are the draft folder, so rmm removes the empty draft and mv takes the comma off message 6. A scan shows the cleaned-up folder. CTRL-D ends the shell and the scandrafts script.
Another section explains how to set up scandrafts.
mhn (in MH, and nmh before version 0.21) and mhbuild (nmh-0.21+) edits drafts that contain directives. (There are examples in the Sections Sending MIME Mail, MIME Draft Directives, and many others.) It replaces the draft with an encoded MIME message, ready to send. You can run mhn by hand, before you send the draft:
What now? edit mhn(or just e mhn). Or, if you use nmh, you can type mime instead.
It can be easy to forget to do MIME processing by hand. If you forget, the recipient will get a message full of your directives -- instead of the encoded MIME message you meant to send. If you want all the messages you send to be MIME messages, you can do MIME processing automatically by adding an MH profile automhnproc: entry -- or, for nmh, automimeproc: and maybe buildmimeproc:. There are advantages and disadvantages; the section Building MIME Drafts Automatically has the story.
Running mhn or mhbuild automatically has another advantage if you use 8-bit (non-ASCII) characters: the minimum required character set (for example, us-ascii for English-only text) will be used. This makes it more likely that people with lousy mail-reading setups can still read what you send.
Whether you run mhn/mhbuild automatically or by hand, though -- after you have some MIME experience, you may not always agree with the automatically-chosen encoding. If you don't use automatic processing, you can edit the encoded draft and change the encoding.
In cases like those, you have a few choices. One is to remember to run mhn or mhbuild by hand when you need it. Another is to add this header field to your draft:
MIME-Version: 1.0When send sees that field, it won't invoke the automatic MIME draft processing. But if you add that field, be sure that your message really is in legal MIME format! (There are too many bogus MIME messages already.)
When mhn or mhbuild reads the directives in your draft message and encodes it, the original draft message file is also preserved for a while. Recovering the original draft takes a little work, but it can be easier than trying to undo what mhn did. For instance, you might have given the wrong filename at the end of a directive, and you don't want to re-enter the whole draft just to fix that one mistake. This section explains how to recover the draft with the original directives. The end of this section describes a shell script that makes the job easier.
Let's start this example by sending a message:
What now? edit mhn (...on nmh, mime) What now? list ...message appears; you see mistake...Use these steps to recover the original directives:
What now? quit whatnow: draft left on /mh/jerry/drafts/3
Here are examples with a draft folder and without. Use backquotes (`), not single quotes ('), in the commands below. The command ls -lt lists the most recently modified files first.
With a draft folder:
% cd `mhpath +drafts` % ls -lt total 357 ... -rw------- 1 jerry 86340 Oct 16 10:46 3 -rw------- 1 jerry 1419 Oct 16 10:43 ,3.orig ...No draft folder:
% cd `mhpath +` % ls -lt total 289 ... -rw------- 1 jerry 86340 Oct 16 10:46 draft -rw------- 1 jerry 1419 Oct 16 10:43 ,draft.orig ...
% mv ,3.orig 3
What now? edit mhn What now? list ...oops... What now? edit original What now? edit viThe original draft, with directives, will open inside your editor. You can fix the problem, save the file, quit the editor, and then type edit mhn again. Here's how to install original. includeFooter('$Date: 2006-05-31 15:13:43 -0700 (Wed, 31 May 2006) $', 'OReilly: 1991, 1992, 1995; Jerry: 1996, 1997, 1999, 2000, 2002, 2004'); ?>