Practical Tips

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

This section has some tips and tricks to help make your .maildelivery setup better.

Finding Mail from Mailing Lists

A lot of mailing lists put one of these fields in their messages:
Precedence: bulk
Precedence: junk
You can catch that mail with entries like this:
precedence,bulk,|,A,"/x/y/rcvstore +later -seq bulkmail"
precedence,junk,|,A,"/x/y/rcvstore +later -seq bulkmail"
The messages will be automatically filed into the later folder and added to the bulkmail sequence in that folder.

Handing Periodic Mail

Do you get a certain message regularly or automatically that you want to be sure your .maildelivery file identifies correctly? The best answer, if it's possible, is to put a unique field in the message. (The Section Draft Message Template Files shows how to do that in MH.) For example, if the message header has:
    ...
To: jerry
X-auto-m-p: monthly report
Your .maildelivery file could match that message reliably with the entry:
x-auto-m-p  "monthly report"  ^  R  "/x/y/rcvpack reports"
If special fields are out of the question, special words or characters in the To: or Subject: field can do it. For instance, these message header fields have special text:
To: ajones, jpeek@jpeek.com (Jerry-report-archiver), bsmith, ...
To: ajones, "Jerry-report-archiver" <jpeek@jpeek.com>, bsmith, ...
The mail will be delivered to jpeek@jpeek.com. The comment will come along with the address and be matched in this .maildelivery entry:
to  jerry-report-archiver  ^  R  "/x/y/rcvpack reports"

Think About cc:, Resent-To:, ...

Mail can come to you via the fields To:, cc:, Resent-To:, Apparently-To:, and more. If it's important to know exactly what address was used -- for instance, if you can get mail through several system aliases (as shown in Section System Aliases, the to and addr Fields) -- then you should consider testing all of those fields and more in your .maildelivery file:
# store book questions to handle later:
to         bookquestions      ^  A  "/x/y/rcvstore +bookq"
cc         bookquestions      ^  A  "/x/y/rcvstore +bookq"
resent-to  bookquestions      ^  A  "/x/y/rcvstore +bookq"
# process book-info subscriptions:
to         book-info-request  |  A  "/u/jerry/bin/book-info-proc"
cc         book-info-request  |  A  "/u/jerry/bin/book-info-proc"
resent-to  book-info-request  |  A  "/u/jerry/bin/book-info-proc"
	...
If you don't care what address was used, it's much easier to use an * (asterisk) or default:
	...
# put everything else in my $HOME/.mailbox file:
default    -     >    ?   .mailbox

System Aliases, the to and addr Fields

If your name is listed in the system mail alias file, people can send you mail without addressing it to your username. On most systems, that alias name stays in the message header, so you can test for it in your .maildelivery file.

For example, here are some of the system aliases I'm on at ora.com:

Jerry.Peek:    jerry
bookquestions: jerry, eric
authors:       ..., jerry, ...
If someone sends mail to Jerry.Peek, bookquestions, or authors, it'll be delivered to my jerry mailbox. I can separate that mail with .maildelivery entries like these:
to      bookquestions ^  A  "/x/y/rcvdist jerry@somewhere.ca"
default -             >  ?  /usr/spool/mail/jerry
The first entry would resend all bookquestions mail to jerry@somewhere.ca, but leave the rest of the mail in my system mailbox.

If I wanted to resend all my mail (to bookquestions, Jerry.Peek, authors, or plain jerry), an entry like this would not do it:

to     jerry ^  A  "/x/y/rcvdist jerry@somewhere.ca"   ...wrong
Instead, to match all mail sent to my mailbox, no matter what alias, I'd use the addr field (or just a default or *):
addr   jerry ^  A  "/x/y/rcvdist jerry@somewhere.ca"
Of course, an easier way to forward all my mail is by putting jerry@somewhere.ca in my .forward file. But this addr example applies to any command, not just resending with rcvdist.

Flagging Important Mail

If you can't read all your mail for some reason -- you're out of your office, unusually busy, or whatever -- you can ask people who send you important messages to mark them "urgent." Your .maildelivery file can catch those messages and handle them specially: forward them to you on the road, use rcvtty to alert you, print them on your secretary's printer (the Section Printing Incoming Mail), or whatever.

For instance, tell people to put the word "urgent" somewhere in the Subject: of your important mail. This entry in .maildelivery will find those messages:

subject  urgent  ^  R  "/x/y/rcvdist jerry@somewhere.ca"

Making Your Mail Follow You

If you're on the road, you don't have to give people a list of the email addresses where they can find you on certain days. Tell them to send to your normal address; let your .maildelivery file send the important mail (with rcvdist) to wherever you are. Each time you move, you or someone in your office can edit your .maildelivery file to forward mail to your new location. Your .maildelivery file can be set to forward only some of your mail; the rest can stay in your system mailbox or be forwarded to someone else.

Splitting Mail to Several Places

The next Example is a .maildelivery file that I worked out for a friend. It has a combination of ideas for splitting messages into a few places automatically.

Example: .maildelivery that routes to several places

# Route all mail from Jim Shankland or Laura Enz to +wordy folder;
# also tell Mark about them so he can check when he has time:
from,shank@foo.com,|,R,"/bin/echo \"Mail ($(size) characters!) from Jim Shankland.\" | /bin/mail markw"
from,shank@foo.com,^,A,"/x/y/rcvstore +wordy"
from,enz@usnd.edu,|,R,"/bin/echo \"Mail ($(size) characters!) from Laura Enz.\" | /bin/mail markw"
from,enz@usnd.edu,^,A,"/x/y/rcvstore +wordy"
# Send first 200 lines of undelivered mail to roady.
# Don't mark it delivered, so it'll also go to lines below:
default,-,|,R,"/x/y/mhl -form roady.mhl -nomoreproc | /bin/sed -e 200q | /x/y/rcvdist rhonda@roady.rspx.com"
# Send complete copy of all undelivered mail to my system mailbox:
default,-,>,?,/usr/mail/rhonda
That long rcvdist pipeline above is interesting. It filters mail sent to the roady computer (a laptop PC with dialup UUCP used to get mail from wherever she's traveling around the world) to make sure that no very long messages waste modem time on international long-distance -- or fill up her disk. (All messages are copied, full length, to her system mailbox.) First in the pipe is mhl with a filter file that strips out fields she won't need on the road. The Example below shows the roady.mhl file in her MH directory. Next, sed truncates any message more than 200 lines long. Finally, rcvdist sends what's left to her UUCP address.

Because the rcvdist pipeline uses the default field, it won't send messages from the long-winded people. The rcvdist entry uses the R result, so it will always send undelivered messages to roady. But the last entry uses the ? (question mark) result, so the only messages written to her system mailbox will be the ones that weren't already filed in the wordy folder.

Example: roady.mhl file filters junk before distributing mail

width=10000
ignores=received,mmdf-warning,x-face
Date:
From:
To:
cc:
Subject:
extras:nocomponent
:
body:nocomponent

[Table of Contents] [Index] [Previous: Alternatives to mhook Programs] [Next: Debugging Tips]


Last change $Date: 1996/06/06 15:12:20 $

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 <jpeek@jpeek.com>