procmail
[Top] [All Lists]

Re: A unique way of dividing up incoming messages

1998-07-02 13:42:34
Excerpts from mail: (02-Jul-98) A unique way of dividing up incoming messages 
by Brock Rozen
Basically, a system of first message goes into folder #1, second goes to
folder #2 and then start again.

This is untested and just off the top of my head.

First, create an INCLUDERC file (I'll call it folder_counter.rc) with one
line in it. It would look something like this:

COUNTER = 0

Then in a different INCLUDERC file (I'll call it splitter.rc) put something
like this:

-------

# Change MAX_FOLDERS to the number of folders that you want incoming e-mail 
# to be split into.

MAX_FOLDERS = 3

# The name of the INCLUDERC file that defines $COUNTER.
COUNTER_FILE = folder_counter.rc

# Prefix for all folder names.
FOLDER_BASENAME = "mbox"

# Use regional lockfile.
LOCKFILE=folder_counter.lock

# Define $COUNTER.
INCLUDERC = $COUNTER_FILE

# Define $FOLDER as a function of $COUNTER.
FOLDER = $FOLDER_BASENAME.$COUNTER

# Increment counter.
JUNK=`(echo -n "COUNTER = "; expr \( $COUNTER + 1 \) % $MAX_FOLDERS ) > 
$COUNTER_FILE`

# Save the message.
:0:
$FOLDER

# Release regional lockfile.
LOCKFILE

-------

Then, in your .procmailrc, to save e-mails using this method:

:0
* whatever criteria
{ INCLUDERC = splitter.rc }

The first message that is received should get filed to mbox.0, the next
message should get filed to mbox.1, the message after that should get filed
to mbox.2, and the one after that should go in mbox.0, etc.

Hope this helps,
Ed

<Prev in Thread] Current Thread [Next in Thread>