# Running Your .maildelivery File

> NOTE: for users of the online version of this book: This section has a lot of examples followed by long explanations. To avoid jumping between the example and its explanation, it's a good idea to open a new browser window to show an example. (Check your browser's menu for a command like New Web Browser or Open in New Window). Then, use the original browser to read the explanation while you view the example in the second browser window.

In most cases, your computer's MTA (see the Section How UNIX Email Works) has to be told to read your .maildelivery file. The list below explains what to do for common transfer agents. If you aren't sure what MTA is running on your system, ask your postmaster -- or read your system's online mhook(1) manual page; it should have been customized automatically for your configuration when MH was installed. (nmh doesn't have an mhook(1) manual page; it's been split into manual pages for rcvtty(1), rcvdist(1), and rcvpack(1).)

- If your computer uses the sendmail or smail MTAs, make a file named .forward in your home directory (note the dot (`.`)). Put the line below, including the double quotes (`"`), in the file:

            "| /x/y/lib/mh/slocal -user username"

  where `/x/y` is the start of the path to the MH library directory where slocal is stored on your computer and `username` is your username. This command sends all your incoming mail through the slocal program.

  Under nmh, slocal can detect and suppress duplicate messages. To enable this, add the option -suppressdup to the slocal command line in your .maildelivery file. slocal will keep a database containing the Message-IDs (from the `Message-ID:` header field) of incoming messages. If you have MH, set the MSGID configuration option or look for an slocal patch file that does the same thing.

  Your .forward file should be owned and writable only by you. (Use the command chmod 644 or chmod 600.)

- If your system runs MMDF II, or (this is unusual!) uses the MH transfer agent, your .maildelivery file will be run automatically. Think about creating .maildelivery with a different name, then renaming it to .maildelivery after you've finished editing it.
- On systems with MMDF, use these two steps:
  1. If you don't have a bin directory in your search path, add it. (The Section Setup Before You Make First New Version explains how.)
  2. Use the UNIX ln command to make a link named rcvmail to the system slocal command. For example:

               % ln /x/y/lib/slocal rcvmail

     If slocal and your bin directory are on different filsystems, a standard hard link won't work. You'll need to make a symbolic link (the ln -s option).

Your .maildelivery file, and the .forward file or link explained above, have to be in your home directory on the computer where your system mailbox file is written. If your own computer gets its mail from another host with POP or by a networked filesystem, check to be sure your setup is on the right computer. If you don't have access to that machine, you can still automate your mail processing with scripts. See the Sections Explanation of autoinc and Processing with at or cron or by Hand.

Here's one more note. At least some MH systems won't run your .maildelivery file unless the mode is 644 -- other users can't edit the file. Even if that isn't required, it's a good idea.