I have been trying to piece this together from old emails and it is failing.
I need a clean section of code (rather than bits and pieces quoted)....
I am trying to match
luomat+BLAH(_at_)luomat(_dot_)peak(_dot_)org and I want to get the BLAH and get
rid of the
"luomat+" and the "@luomat.peak.org"
Now the blah may be one word or several, such as this:
luomat+usenet(_at_)luomat(_dot_)peak(_dot_)org
luomat+Lists/procmail(_at_)luomat(_dot_)peak(_dot_)org
Note: I am only using 1 plus sign, the first one after my username.
Anything after that will be separated by /
There could also be something like this:
luomat+Lists/Misc/apache
What I would like to do is test for the existence of the directory if there
is a "/" present (ie $MAILDIR/Lists or $MAILDIR/Lists/Misc/)
If the directory is not there, I want to try 'mkdir' and then I want to put
the message in whatever mailbox is BLAH, ie:
usenet
Lists/procmail
Lists/Misc/apache
I'm sorry I can't seem to figure this out on my own....
I can't figure out how to:
Not have the domain end up as part of the $MATCH:
* ^TO_luomat\+()\/.*\@
How to get the directory, if any which comes after the + and before
the @ (ie /Lists or /Lists/Misc in the examples above)
Here is as close as I seem to have ever gotten:
# NOTE: Appnmail is a NeXT program which does it's own locking
LOGNAME=luomat
:0
* ^TO_$LOGNAME\+()\/.*
{
:0
* MBOX ?? ^^\/.\ # This needs to be the directory
{
DIR=$MAILDIR/$MATCH
#
# NOTE: my mkdir can do mkdir -p /some/dir/
# with trailing slash
#
:0wic
* ? test ! -d "$DIR"
| mkdir -p "$DIR"
# Do this if the directory should have been made
# but failed
:0e
| $APPNMAIL $IN/PlussedMisc
}
:0w
| $APPNMAIL $DIR/$MATCH # this needs to be between
# the + and the @ !!!
# If the message has not been delivered by now,
# send it to Misc
:0ew
| $APPNMAIL $IN/PlussedMisc
}
Thanks again
TjL