procmail
[Top] [All Lists]

Re: How can I change a domain or extract only a username from ^TO

2005-06-03 08:17:12
On Fri, Jun 03, 2005 at 04:52:37PM +0200, Dallman Ross wrote:

As ever, though, when using procmail to send mail out, you
should first append an X-Loop header, and of course be testing
for same on the way in:

 :0 fw h
 * ^Return-Path:.*<\/(_dot_)*(_at_)domain1(_dot_)com>
 *  MATCH ?? ^^\/[^(_at_)]+
 | formail -I "X-Loop: $MATCH(_at_)domain1(_dot_)com"

   :0 a  # implies A
 | ! $MATCH(_at_)domain2(_dot_)com

Come to think of it, we can check for X-Loop's existence
in the very same rcipe, killing two birds with one stone.


  :0 fw h
  *    ^Return-Path:.*<\/(_dot_)*(_at_)domain1(_dot_)com>
  * $! ^X-Loop:(.*\<)?$\MATCH?$
  *    MATCH ?? ^^\/[^(_at_)]+
  | formail -I "X-Loop: $MATCH(_at_)domain1(_dot_)com"
 
    :0 a  # implies A
    ! $MATCH(_at_)domain2(_dot_)com

Note that I'm using the "?" in the second condition to
effectively get rid of the ">" even though it's still there.  :-)


Here's an alternative:

  :0 fw h
  *    ^Return-Path:.*<\/(_dot_)*(_at_)domain1(_dot_)com>
  *    MATCH ?? ^^\/.*[^>]
  * $! ^X-Loop:(.*\<)?$\MATCH$
  | formail -I "X-Loop: $MATCH"
 
    :0 a  # implies A
    *  MATCH ?? ^^\/[^(_at_)]+
    ! $MATCH(_at_)domain2(_dot_)com


One MATCH-reparse extra, but probably algorithmically cleaner.

-- 
dman

____________________________________________________________
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