$book = '..'?>
include "$book/mh.php"; includeHeader('e-append.html', 'e-automh.html'); ?>The Section Batch-process New Mail: autoinc introduces autoinc, a script for running inc and processing each new message. It's designed to be run automatically from a cron or at job but you can also type its name at a shell prompt. Here is the autoinc script (you might want to open it in a separate browser window). To install it, see the Section Programs in This Book's Archive.
Before incorporating mail, it tries to be sure that there's enough disk space by checking your disk quota. If your system doesn't have disk quotas -- or even if it does -- you might also want to have autoinc run df to see if there's enough disk space left on your filesystem before it incorporates all your mail. (This test isn't completely accurate. Once the mail has been incorporated, each message will take at least one disk block -- but the test doesn't account for that extra disk usage. The margin shell variable can work around that problem.) If the user doesn't have enough room, autoinc sends mail to some address (probably not yours!) to complain. You can hack autoinc to notify the user in some other way.
Two places in the script use sed "tagged fields" to grab certain fields from the output of df and quota -v. Some people use awk to do this, but sed usually runs faster. For example, the second sed filter outputs a line like the following for the shell's eval command to read:
used=1345 total=2048That sets two variables, $used and $total, from the output of quota -v.
An ls -s command stores the mailbox size in $2. (Read about the set x trick in the Section Explanation of showpr.) If you're using inc with POP, that won't work, of course. But you can parse the output of msgchk -- use another sed expression to find the number nnn in the string (nnn bytes).
When autoinc incorporates new mail, it starts a loop to scan the messages one by one. The script uses the techniques in the Section Get Information with scan Format Strings to get information from the header of each message. To make autoinc do whatever it is you want it to do, you'll need to customize the body of the loop that scan drives. Right now, it's full of dummy case statements like this:
case "$from" in aaaa|bbbbb|ccccc|ddddd|eeeeeeee|fffffff|ggggggg|hhhhhh) $mh/refile $msg +$from continue ...Of course, your loop can use any tests it needs to. Or, you might not want to use a loop at all. Depending on what you need, a few commands like the one below could be more efficient:
pick --sender a -or --sender b ... -seq temp && refile temp +xWhile you're debugging autoinc, remember the inc -notruncate switch. It incorporates your new mail but doesn't remove the messages from your system mailbox. That way, you can incorporate and test the same messages over and over.
A set -e command makes the shell quit if any command returns a nonzero status. If there's a problem, just fix it and rerun autoinc by hand. When you rerun autoinc, it will look through all the leftover mail in inbox as well as any new mail it incorporates. includeFooter('$Date: 2006-05-31 15:13:43 -0700 (Wed, 31 May 2006) $', 'OReilly: 1991, 1992, 1995; Jerry: 1996, 1997, 1999, 2000, 2002, 2004'); ?>