If you receive messages that should be sent to other people, use rcvdist. It does the same thing as the MH dist command. rcvdist adds a Resent-...: field, with one or more new addresses, to the message -- then resends the message. Here are some ways to use rcvdist:
source mh-users-request ^ R "/x/y/rcvdist lisa email@example.com"Try not to use any spaces within an address. If you have to do it, remember to put escaped double quotes (\") around that address:
from root ^ R "/x/y/rcvdist \"The Guru <firstname.lastname@example.org>\""Unless you need to use the pipe or | action, it's much better to use the qpipe or ^ action. That way, if your addresses are single words with no space in them, you won't have to worry about shell quoting. For instance, the entry below works fine with qpipe (^) -- but it doesn't work with pipe (|) because the shell would interpret < and > as redirection characters:
to managers ^ R "/x/y/rcvdist <jane> <email@example.com>"If you have to use special characters and the pipe or | action, protect the addresses with single quotes (') or escaped double quotes (\"). For more about quoting, check UNIX Power Tools or any good shell programming book in the Reference List.
By default, rcvdist ignores your MH aliases. If you need to use aliases, run the ali -list command inside backquotes. For example, to re-send all managers mail to your MH alias named supervisors:
to managers ^ R "/x/y/rcvdist `/x/y/ali -list supervisors`"
Resent-Fcc: outboxThat field drops a copy of the redistributed message into your folder named outbox. (See the Section Fcc: Folder Copies.) You don't have an outbox folder, you say? You will after you run rcvdist.
The folder copy is made by the default rcvdistcomps file. Your system administrator may have modified rcvdistcomps, so things may be different on your system. If you want folder copies to go to another folder, or no folder copies at all, you can make your own rcvdistcomps file.
Every so often, you might remove old folder copies made by rcvdist. One way to do that automatically is by modifying the rm_msgs scripts in the Section Remove Messages from rmmer. The scripts could clean up your outbox folder as well as the DELETE folders they're designed for.
For example, let's say you're one of the people on the system alias called managers. You want to reroute all status reports to the other managers automatically. Don't do it this way:
subject "status report" ^ R "/x/y/rcvdist managers" ...wrongUnless your system mailer is smart enough to catch problems like this, rcvdist will send your message to managers, that alias will route the message back to you, rcvdist will send it to managers again, and so on... (If a loop starts, you can stop it pronto by editing your .maildelivery file and adding a hash mark (#) at the start of the entry with the rcvdist command.)
The best fix is to replace managers in that rcvdist command line with all the managers' addresses except yours. But that can fix be tough to do if the members of managers change often -- or if the alias is on another computer and you can't find out what addresses are on it.
A workaround: make your own rcvdistcomps file -- you might name it rcvdistcomps.noloop. The file should add a special comment field to the message rcvdist resends:
Resent-comments: noloop(There's nothing special about the word noloop; you can use any word.) Next, in your .maildelivery file, on the entry before rcvdist, add an entry that will destroy messages with that special field. Be sure that the rcvdist entry uses the ? (question mark) action so it won't be executed if the previous destroy succeeds:
resent-comments,noloop,destroy,A,- subject,"status report",^,?,"/x/y/rcvdist -form rcvdistcomps.noloop managers"How does it work? The first time a status report comes in, rcvdist will add your new Resent-comments: noloop field and send the message to managers. When the message comes back from managers to you, though, .maildelivery will match that special field -- and destroy the message before rcvdist can send it again.
A dirty fix? Maybe. But, at least, it's a good demonstration of how these mhook utilities can be combined.
[Table of Contents] [Index] [Previous: Storing in Folders: rcvstore] [Next: Storing in Mailbox Files: rcvpack]
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 <firstname.lastname@example.org>