procmail
[Top] [All Lists]

Re: substituting for dirname

1998-02-08 15:36:24
Timothy Luoma asked me,

| So are you suggesting this? (assuming me do not want to do a
| recursive INCLUDERC)

Let's see.

| :0
| * ^(To|Cc):.*luomat\+()\/.*

I'd rather make it more flexible:

  * $ ^TO_$LOGNAME\+\/.*

| {

At this point we need something -- either the recursive INCLUDERC or the
tr call -- to change the pluses to slashes and to get the result into the
MBOX variable.

|       :0
|       * MBOX ?? ^^\/.+/
|       {
|               DIR=$MAILDIR/$MATCH
| 
|               :0ic
|               * ? test ! -d "$DIR"
|               | mkdir -p "$DIR"

If mkdir fails, we might as well drop it into $DEFAULT right now:

                :0e:
                $DEFAULT
|       }

What if there was only one plus sign, so $MBOX now contains no slashes?

       :0E
       { DIR=$MAILDIR }

|       # NOTE: I want to keep this check here in case
|       # there is a directory with the same name
|       # that I wanted for the mailbox, ie if I use
|       # luomat+lists+procmail and someone sends mail
|       # to luomat+lists

OK; another possibility was to save such items to that directory (as
individual files or into a default folder).

|       :0w :
|       * ? test -d ${DIR} -a ! -d $MBOX
|       $MBOX

We don't need to test -d $DIR; if we got this far, we know it's there.

|       # If the message has not been delivered by now,
|       # send it to $DEFAULT
|       :0 :
|       $DEFAULT
| }

OK.

| What happens when there is just one + sign?

That's why I added the else recipe.  MBOX should then be set to whatever is
after the plus sign, implying a file in $MAILDIR.

| What happens when I am only one of many people listed on the 'To|Cc' line?

That should be no problem, unless you meant that you want to do this only
for mail where you are the sole listed recipient.

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