Chapter Introduction (Processing New Mail Automatically)

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

This chapter describes a set of MH programs that handle new mail for you. Here are some of the reasons you might want to use these mhook (mail hook) features:

The mhook utilities can do those things, and many others, automatically. The mhook(1), slocal(1), maildelivery(5), and rcvstore(1) manual pages have some details. Note that versions of MH before 6.8 don't have a slocal(1) manual page; the slocal information is in the mhook(1) manual page. Also, at least one vendor doesn't have an mhook(1) manual page; all their information is in slocal(1). Finally, nmh doesn't have an mhook(1) manual page; it's been split into manual pages for rcvtty(1), rcvdist(1), and rcvpack(1).

This chapter has much more about setting up and using these programs. (xmh and exmh users can use these features as well as a special .xmhcheck file, explained in the Sections Incorporate New Mail and Mail Filtering File Examples.)

The mhook utilities are usually set up with a file named .maildelivery in your home directory. (You can run the utilities from another program or from the command line. For example, a shell script of mine uses rcvdist to send Usenet news articles through email.) Each new message is checked against the entries in .maildelivery. Each entry in the file describes the kinds of mail messages it will match -- and the name of a program to run or a file to write when a message matches. The Section The .maildelivery File: Overview has an introduction and the Section The .maildelivery File in Detail has more information.

On systems with the Sendmail MTA (mail transfer agent), you run a special MH program named slocal from the .forward file in your home directory -- and slocal will read your .maildelivery file. The slocal program adds some extra complication and its own quirks to the process. There are several sections of this chapter that are only about slocal, not about the .maildelivery file in general. Life is a little easier on systems running the MMDF II transfer agent. They don't need slocal because MMDF II will read your .maildelivery file automatically. There are a couple of other variations. See the Section Running Your .maildelivery File for more info.

The Section Experimenting? Make Backups! has techniques to keep you from losing mail while you experiment. Next are sections about four MH programs run from your .maildelivery file:

Those programs won't be enough for everybody, so the Section Alternatives to mhook Programs discusses other ways to handle your mail automatically. The Section Practical Tips is a lot of fun: a bag of tricks for combining these programs with the shell and other utilities. Finally, Section Debugging Tips has tips for debugging.

CAUTION: Most people depend on getting email reliably. Remember that you can lose some or all of your incoming mail if your automatic mail handling isn't working right.

If mail to your account fails and "bounces" back to the people who send it, they can be confused. If you're on a mailing list, and the list's messages to you bounce back, the list's owner may take you off the list.

Don't worry! Just be careful. If you have a second account, where you can experiment without losing important mail, test this setup there before putting it on your own account. Otherwise, while you're setting up and debugging your new setup, make copies of all your incoming mail -- the Section Experimenting? Make Backups! explains how.

[Table of Contents] [Index] [Previous: MH Format Strings] [Next: The .maildelivery File: Overview]

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 <>