Forwarding Messages with forw

[previous] [next] [table of contents] [index]

The forw command lets you send copies of one or more messages to other people. Here is an introduction to forw.

Formatting Forwarded Messages

By default, every line of the message(s) you're forwarding is sent. If a message header is full of "junk" fields like Received: xxx, you can save space on the copy you forward by telling forw to omit those fields. You can also control the formatting of the rest of the header and/or body -- line up header fields neatly or rearrange them into a standard order, shorten lines in the body that are too long, and so on.

It's easy to get the most common formatting. If you use the -format switch, forw will process the message(s) you're forwarding with an mhl filter file. Your system should have a standard file called mhl.forward that:

To use it, just type:
% forw -format
If you want to use this filtering on most of the messages you forward, you may want to add this entry to your MH profile:
forw: -format
Before forw checks the MH library directory for an mhl.forward file, it looks in your MH Mail directory. If you don't like the system mhl.forward file, you can copy the system mhl.forward file into your directory and then edit it:
% cd Mail
% cp /usr/local/lib/mh/mhl.forward .
% vi mhl.forward
(You'll need to change the /usr/local/lib/mh if your system's MH library directory is someplace else.)

forw gives you another choice: using a different filter file than mhl.forward. That can be handy if you forward different kinds of messages. You might have a second filter file that includes Resent: fields from the original message, a third filter file that reformats the message body for a friend who has a 40-character-wide display, and so on. The Section forw Filter Files explains how to make your own.

If you set -format or -filter as a default in your MH profile, you can override either one of those switches by using -noformat as you type the forw command line.

Adding Text to the Draft

By default, forw will prompt you for the header fields; then it prompts you to:
--------Enter initial text
After you enter the initial text, forw will scroll the body of the forwarded message(s) across your screen. The "initial text" gives you a chance to type some extra text -- for instance, you could write a note to the people who you're forwarding this to.

But you may not like the way that works. If you want the note you write to go after the forwarded message(s), add the -noprepend switch to the prompter: entry in your MH profile. Unfortunately, though, that changes the way prompter works for all message-sending commands, not just forw. The Section Append Text with prompter.nopre has a solution.

Leave My Dashes Alone

Another thing some people don't like about forw is the way that it adds an extra dash and space (- ) before any line which starts with a dash. For example, text that looks like this in the original message:
- Add one cup water.
- Cook for 25 minutes.
will be forwarded this way:
- - Add one cup water.
- - Cook for 25 minutes.
That's special formatting called "bit stuffing" that helps the MH burst command split forwarded messages back into separate message files. (There's a detailed description in RFC 934; see the Reference List.) One problem with that format comes when messages are nested many levels deep: the lines starting with dashes can get so long that they may be truncated by some message transports. Or you may not like the extra stuff (- ) at the beginning of dashed lines. The forw -mime switch forwards messages without bit-stuffing. (On the other hand, forw -mime -rfc934mode uses a MIME format that simulates bit-stuffing.) Not everyone has MIME yet, though. If you have nmh version 0.26 or above, the -nodashstuffing switch prevents bit-stuffing. In earlier nmh versions, and in MH, you've got the almost-undocumented -nodashmunging switch. (It's mentioned in "The RAND MH Message Handling System: Administrator's Guide, UCI Version.")

Of course, you should not use -nodashstuffing or -nodashmunging if the person you send the message to will want to burst it.

NOTE: The -nodashmunging switch only works in combination with -format or -filter and a filter file:

% forw -nodashmunging -format
This makes MH and nmh before version 0.26 a bit of a pain to use. Worse, if you don't want any formatting, you can't use both -noformat and -nodashmunging to get it. The best answer for that is to get nmh! ;-) Otherwise, try a filter file that does no formatting. Here's one that I call mhl.noformat; you can put it your MH directory. (You can also get this little file from this book's online archive. It's in download/split/mh/Mail/mhl.noformat.)
If you want long body lines wrapped after the 79th character, add ,width=80 (with no space before it) to the end of the last line.

You use mhl.noformat by typing its name on the command line (which overrides any default mhl.forward), like this:

% forw -filter mhl.noformat -nodashmunging
mhl.noformat doesn't delete any header fields, and it leaves long lines as they are in the original message. For more information, see the Section forw Filter Files.

Make Your Messages burst-able

It's always a good idea to leave a blank line between the initial text you type (if any) and the starting line (------- Forwarded Messages). That's because the message encapsulation guidelines in the document RFC 934 say that there must be a blank line before the forwarded messages. This lets message-bursting programs like burst separate the header of the total message from the header of the first forwarded message. If you enter initial text, be sure to press RETURN at least one extra time after you finish.

You don't have to follow this rule when you're forwarding a message with the MIME #forw directive -- before you encode the message. After you encode it with edit mhn (or in nmh, mime), be careful about the space between the parts. Also see the Section Forwarding in MIME Format.

Formatting the Header

When forw prompts you for To:, cc:, and Subject:, it reads a default header file called forwcomps from the MH library directory. You can make your own forwcomps file -- in your MH directory. But forwcomps has the same syntax as the components file that comp uses. Because I want the same default header for both forw and comp, I tell forw to use my components file instead. So if I ever change my components file, I won't have to remember to change forwcomps, too. This entry in my MH profile does the job:
forw: -form components
Unlike the replcomps file for repl, there's no special MH-format processing done on the header of the draft message. (I'm not talking about the header of the message which is being forwarded; it is formatted with MH format. I'm talking about the header of the outer message, the message which contains the forwarded message.)

One workaround for this is to set up the MH command version called forwr. It uses repl to simulate forw; you can control the apparance of the header and the forwarded message. This trick has a couple of problems, though: repl can forward just one message at a time, and it doesn't use bit stuffing.

Probably the most common request for forw is handled by the forwedit script. forwedit sets the Subject: header field of your draft forwarded message to be the same as the subject of the original message with (fwd) after. If you forward more than one message, it uses the subject "Forwarded messages". (You can configure this.) After doing that, forwedit calls an editor (vi, for example) for you to compose the draft header and body. For example:

% scan cur
  50+ 05/20 SunWorld Editor-i  Who will run the Internet?<<The latest issue
% forw
To: someone@somewhere
Subject: Who will run the Internet? (fwd)
You can change the Subject: format and make other tweaks. For more information and installation instructions, read the Explanation of forwedit.

Annotating the Original Message

If you use the -annotate switch on the forw command line or in your MH profile, the message you forward will have fields like this added to its header:
Forwarded: Mon, 09 Jan 1995 09:13:52 -0500
These let you know that you forwarded the message to al@phlabs and when you did it. There will be one Forwarded: user@host field for each address you forward the message to.

By default, scan looks for Replied: fields in messages, but it doesn't look for Forwarded: fields. If you want to, you can add that yourself, though; see the Section More Header Information: scan.hdr.

Creating Digests

The forw command can create message digests. Digests combine one or more messages in a format similar to an MH forwarded message. Digests are usually sent periodically to a list of users (a mailing list). Each digest message has its own volume and issue numbers; MH can keep track of these for you and increment them automatically. (The numbers are kept in the context file. The Section Settings from the MH Profile shows how to get the volume and issue numbers for the last digest sent.)

Here's an example. You're taking over as moderator of the octopus-eaters mailing list from someone on another computer. Before the first issue, you store the recipients' addresses in an MH alias named dist-octopus-eaters. You ask your system postmaster to create a system alias named octopus-eaters-request with your name; this is where people send mail if they want to be added to or deleted from the mailing list. The postmaster also creates an octopus-eaters mail alias where people can send messages to be included in your digest. If you get much mail for the list, you can set up automatic processing to file the mail into separate folders.

After you're set up, you can send a digest. The first issue you're sending is volume 1, issue 26. To send messages 66-73 in the digest:

% forw -digest octopus-eaters -volume 1 -issue 26 66-73
From:     octopus-eaters-Request
To:       octopus-eaters Distribution: dist-octopus-eaters;
Subject:  octopus-eaters Digest V1 #26
Reply-To: octopus-eaters

--------Enter initial text

Hi.  I'm Emma H. User, the new moderator of octopus-eaters.
Send submissions to:


octopus-eaters Digest   Monday, 16 Jun 1997
                Volume 1 : Issue 26

Today's Topics:

	...Messages appear...

End of octopus-eaters Digest [Volume 1 Issue 26]

What now?
The To: field has an RFC822 group name, octopus-eaters Distribution:, as well as the name of your distribution alias, dist-octopus-eaters; (notice the semicolon at the end). When MH sends the message, it will remove the alias name; the To: header field in recipients' messages will look like this:
To:       octopus-eaters Distribution ;
This keeps the recipients' addresses confidential in most cases. There's more about RFC822 groups in the Section Message Transfer; Sighted and Blind Recipients.

The header setup can be stored in your MH directory in a replcomps-style file named, by default, digestcomps. You can customize digestcomps. If you run more than one digest, creating some versions of forw can save time.

For the next issue, just type forw -digest octopus-eaters. MH will automatically assign volume 1, issue 27, unless you override it.

Another way to create message digests is the forw -mime switch. It doesn't have the nice numbering and formatting features of forw -digest, though.

Forwarding in MIME Format

The forw -mime switch simply builds a draft message with a #forw directive in it. (Parts of the Section Composing and Sending MIME Messages cover #forw.) If you encode the draft with the mhn -rfc934mode switch, mhn will simulate RFC 934-style "bit stuffing," as in the Section Leave My Dashes Alone.

Another way to forward in MIME format is to use comp -- and put #forw directives in the draft. This lets you forward messages from more than one folder. It won't annotate the messages you forward, but you can use the anno command to add Forwarded: fields to the original messages.

One disadvantage of forw -mime (compared to plain forw) is that it overrides the -filter and -format switches. All header fields, including "useless" fields like Received:, are copied from the forwarded messages. (Actually, as with many MH switches, the order that forw reads the switches determines which switch will "win." The last switch in the group -mime, -filter and -format is the one that's used. forw reads the MH profile before reading its command line. So, if you have -filter in your MH profile and you run the command forw -mime, the -mime switch will override -filter. As another example, if you type forw -mime -format, the -format switch will win because it comes last on the command line.)

If you want to use MIME format but you also want to filter out useless header fields, see the trick in the Section Filter Forwarded MIME Messages: mforw. The mforw version shown there is actually a link to the repl command that edits a message and forwards it in MIME format. That mforw version only forwards one message at a time, though. To forward several messages with cleaned-up headers or to build a MIME digest, the easiest method I know is to use forw -mime; run edit mhn (or, in nmh, mime); then edit the message by hand (with a command like edit emacs).

[Table of Contents] [Index] [Previous: Replying to Mail with repl] [Next: Distributing Messages with dist]

Revised by Jerry Peek. Last change $Date: 1999/10/10 05:14:05 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <>