The .maildelivery File: Overview

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.

Without a .maildelivery file, when new mail arrives, your computer's MTA drops it in your system mailbox. The entries you put in your .maildelivery file will control what happens instead. This section gives an overview. The Section The .maildelivery File in Detail has more info.

NOTE: You should not perform the steps in this section, to set up your .maildelivery file, yet. Instead, give the file another name. When you're ready to use the file, follow the instructions in the Section Running Your .maildelivery File for enabling the file. Rename your temporary version to .maildelivery then.

When a new message comes in, the .maildelivery file is read entry by entry, from top to bottom. If an entry matches the incoming message, an action on the entry stores the message in a file or passes the message to a command listed on that entry. Then, in most cases, the message will be flagged as "delivered." Following entries in .maildelivery can test whether the message has been delivered by a previous entry.

The system is fairly easy to understand and set up. It's not as flexible as you might want it to be, but you can work around most of the problems.

Let's look at the simple .maildelivery file in the next Example. The line numbers to the left of each line (like 2>) are not part of the file; they are for reference only. Entries starting with a hash mark (#) are comments that explain the following entry. Comments aren't required, but they're a good idea! (You can also get the file, without line numbers, from this book's online archive. It's in examples/mh/misc/maildelivery-1.)

Example: Simple .maildelivery file

    1> # Throw away all mail from this guy:
    2> from     flamer@xyz.abc  destroy A  -
    3> # File VAX mailing list in +vax folder; I read it later:
    4> subject  "vax digest"    qpipe   A  "/x/y/rcvstore +vax"
    5> # Put the rest into my maildrop:
    6> default  -               file    ?  /usr/spool/mail/jerry
    
In general: You can do a lot more than that simple example shows. The Section The .maildelivery File in Detail explains the syntax of .maildelivery. Sections after it cover rcvstore and other programs.