This is possible, though it requires some rather obscure Procmail features, and of course, you need to understand what you are achieving.
:0
* ^From:[ ]*\/[^ ].*
* $ ^To:[ ]*$\MATCH
{ ... actions ... }
The \/
capture operator collects the matching string into the special variable MATCH
. On the next line, we search for the same string in the To:
header. Where $MATCH
contains the captured string, $\MATCH
contains a regex where any regex special characters in the string have been escaped so as to match literally. The $
modifier is required on the recipe in order to allow interpolation of Procmail variables into the regex.
This uses the usual [ ]*
(space or tab, zero or more) to skip over whitespace after the colon, then grabs everything starting from the first non-whitespace character.
In practice, this means that the From:
and To:
headers have to have identical contents. If the sender puts in a different "real name" (which technically is just a comment), this recipe will fail to match. For example,
From: Myself <me@example.net>
To: Everyone <me@example.net>
Here, the email terminus is identical, but the whole field is different. If you need to cope with this scenario, maybe change the regex to match up through the first <
before the \/
but this will obviously depend on the precise strings you need to match; there are many possible variations.