On Tue, Jun 07, 2005 at 04:32:46PM +0200, Daniel Siechniewicz wrote:
On Fri, 03 Jun 2005 17:11:14 +0200
Dallman Ross <dman(_at_)nomotek(_dot_)com> wrote:
: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
Thank You very much, BUT... :) I'm trying to apply these rules,
changing ^Return-Path: to ^TO_ (or ^TO), as there's no return-path
header. Well, it doesn't work either way :-/. Procmail does process the
mails, if I feed it with simple forwarding it works all right. So I
guess there must be something wrong with the rules, or with the way I
try to modify them.
Well, of course it doesn't work with ^TO_ instead without some work
on the recipes. That's kind of like saying, "Your recipe [pun intended]
that described how to make a cherry pie doesn't work for me when I
substitute oranges. So I guess there's something wrong with
the recipe . . . ." :-)
First we need to see what happens with ^TO_. Do you have a test
harness (a.k.a. sandbox)? Search for those terms in the list
archives. Do you realize that ^TO_ isn't going to help you with
bcc's, many mailing lists, and so on? Here's what happens with the
message of your I'm responding to from the procmail list when I try
to find my name that way:
1:29am [~/Mail] 502[0]> frm proclist
Daniel Siechniewicz Re: How can I change a domain or extract only a
username
1:29am [~/Mail] 503[0]> cat \^TO_.rc
:0
* ^TO_\/dman(_at_)nomotek[(_dot_)]com\>
{ TEST = $MATCH }
1:29am [~/Mail] 504[0]> procmail -m DEFAULT=/dev/null VERBOSE=y \^TO_.rc <
proclist
procmail: [12588] Wed Jun 8 01:29:49 2005
procmail: Assigning "MAILDIR=."
procmail: Rcfile: "^TO_.rc"
procmail: No match on
"(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)\/dman(_at_)nomotek[(_dot_)]com\>"
procmail: Assigning "LASTFOLDER=/dev/null"
procmail: Opening "/dev/null"
From procmail-bounces(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE Tue Jun 7
16:41:28 2005
Subject: Re: How can I change a domain or extract only a username from ^TO
Folder: /dev/null
5625
See that long line? No match. Hmm. Is my address there?
1:31am [~/Mail] 508[0]> grep dman(_at_)nomotek\(_dot_)com proclist
for <dman(_at_)nomotek(_dot_)com>; Tue, 7 Jun 2005 10:41:23 -0400
(EDT)
dman(_at_)nomotek(_dot_)com; Tue, 07 Jun 2005 16:40:59 +0200 (MEST)
Dallman Ross <dman(_at_)nomotek(_dot_)com> wrote:
Yes, it's there in two of the Received headers and it's there in the body.
No place the ^TO_ macro can find it, though.
But okay, assuming you still want to do this, if we capture the address
with the ^TO_ macro in a simple case, it would work like this:
TESTADDY = 'procmail(_at_)lists[(_dot_)]RWTH-Aachen(_dot_)DE'
:0 fw h
* $ ^TO_\/$TESTADDY\>
* MATCH ?? ^^\/.*[a-z]
* $! ^X-Loop:(.*\<)?$\MATCH$
| formail -I "X-Loop: $MATCH"
:0 a # implies A
* MATCH ?? ^^\/[^(_at_)]+
! $MATCH(_at_)nomotek(_dot_)com
That works fine. See below for the verbose procmail log. It mailed
the list message to me at procmail@ my domain. I will make more comments
after the log:
1:44am [~/Mail] 525[0]> procmail -m DEFAULT=/dev/null VERBOSE=y \^TO_.rc <
proclist
procmail: [3315] Wed Jun 8 01:44:13 2005
procmail: Assigning "MAILDIR=."
procmail: Rcfile: "^TO_.rc"
procmail: Assigning
"TESTADDY=procmail(_at_)lists[(_dot_)]RWTH-Aachen(_dot_)DE"
procmail: Assigning "MATCH="
procmail: Matched "procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
"
procmail: Match on
"(^((Original-)?(Resent-)?(To|Cc|Bcc)|(X-Envelope|Apparently(-Resent)?)-To):(.*[^-a-zA-Z0-9_.])?)\/procmail(_at_)lists[(_dot_)]RWTH-Aachen(_dot_)DE\>"
procmail: Matched "procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE"
procmail: Match on "^^\/.*[a-z]"
procmail: Match on !
"^X-Loop:(.*\<)?()procmail(_at_)lists\(_dot_)RWTH-Aachen\(_dot_)DE$"
procmail: Executing "formail,-I,X-Loop:
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE"
procmail: Matched "procmail"
procmail: Match on "^^\/[^(_at_)]+"
procmail: Assigning "LASTFOLDER=/usr/sbin/sendmail -oi
procmail(_at_)nomotek(_dot_)com"
procmail: Executing "/usr/sbin/sendmail,-oi,procmail(_at_)nomotek(_dot_)com"
From procmail-bounces(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE Tue Jun 7
16:41:28 2005
Subject: Re: How can I change a domain or extract only a username from ^TO
Folder: /usr/sbin/sendmail -oi procmail(_at_)nomotek(_dot_)com
5594
First comment: The [a-z] thing in the second condition is because I want to
stop matching on the last letter in the domain of the address, and drop the
'\>' char that I will have captured with my regex by way of having used a
right anchor to make the regex more robust.
Second comment: Do not stick that exact recipe in your setup with my domain's
address in there! I do not want all your forwards!!!! I'm serious. I bet
it will happen. I'm going to start getting cruft and spam to that address.
(I've been being Joe-jobbed for days lately with Message-ID attacks at that
domain, for what it's worth.)
--
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