On Fri, Mar 5, 2010 at 5:52 AM, Patrick Plattes
<patrick(_dot_)plattes(_at_)niemann-frey(_dot_)info> wrote:
:0H
* ^TO(.*)@foo.net
! $1(_at_)bar(_dot_)net
To simply answer the question, what you want is the ^TO_ macro, not
the ^TO macro:
:0 # The H is implicit and, if present, tickles a bug in some
versions of procmail
* ^TO_\/[^(_at_)]*@foo.net
* MATCH ?? ()\/.*@
! ${MATCH}bar.net
The \/ operator assigns the stuff on the right of it to $MATCH. So this means
(1) find the first @foo.net address in any of the normal delivery
headers and store in $MATCH
(2) find everything in $MATCH up to the @ sign, i.e. the left hand
part, and store that
(3) forward to that, but using bar.net
However, as others have pointed out, if you're trying to do this for
all mail you're going to fail in any instance where the recipient was
Bcc'd or where there are multiple foo.net addresses in the header.
Ideally you just want to bypass parsing the headers and try to discern
the left-hand-side from the user identity for whom the procmail
process was invoked, like this:
:0
! $LOGNAME(_at_)bar(_dot_)net
Or if the users are virtual so that $LOGNAME is meaningless, perhaps this:
:0
* MAILDIR ?? .*/\/[^/]*
! $MATCH(_at_)bar(_dot_)net
Or if $MAILDIR doesn't end in the user name of the recipient, perhaps this:
:0
* DEFAULT ?? .*/\/[^/]*
! $MATCH(_at_)bar(_dot_)net
The solutions proposed by LuKreme and Charles assume that you have a
catch-all dropbox so that the user and mailbox names at foo.net are
always the same and therefore can't be used in this way.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail