# Processing New Mail Automatically

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:

- Do you get a lot of mail? Is some of it from mailing lists or system programs that you want to file and handle later, some of it that you want to leave in your system mailbox, and some that's urgent (like mail from a system-monitoring program) that you want to see right away?
- Does your mail need handling while you're out of the office?
- When new messages come in, do you want to find out right away?

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:

- New Message Notification: rcvtty on rcvtty, to notify you about new messages.
- Storing in Folders: rcvstore about rcvstore, to store messages in folders.
- Redistributing Messages: rcvdist covers rcvdist, for redistributing messages to other addresses.
- Storing in Mailbox Files: rcvpack explains rcvpack, which saves messages in files.

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.