You have the prologue line and the condition in the wrong order. But in addition, Procmail does not recognize the Perlism \d
. (See e.g. here for a bit of regex history and arcana.) Try this instead:
:0:
* ^To:.*me-\/route[0-9]
/home/me/folder-$MATCH/afile
or, if you really want to verify that the matching expression is immediately followed by an @ sign,
:0:
* ^To:.*me-\/route[0-9]@
* MATCH ?? ^\/route[0-9]
/home/me/folder-$MATCH/afile
From the input To: reallynotme-route2@example.com
, the first condition captures route2@
and the second condition matches up through route2
in order to drop the trailing @
from MATCH
.
My suspicion is that no lock file is necessary, so the second colon should be removed, but this depends on what afile
is. If it's a regular Berkely mbox file, you should definitely use locking. If it's a Maildir folder, you should not.
You might also want to look into replacing ^To:.*me
with ^TO_me
-- it will match on Cc:
and other pertinent headers as well as a literal To:
header, and avoid matching on reallynotme
.