Please do *not* remove the mailing list from the Cc: header, unless
there is a very good reason (i.e. confidential information in the
message text).

On 2005-10-23 19:11, stan <[EMAIL PROTECTED]> wrote:
>On Mon, Oct 24, 2005 at 01:13:18AM +0300, Giorgos Keramidas wrote:
>>On 2005-10-23 17:49, stan <[EMAIL PROTECTED]> wrote:
>>>On Sun, Oct 23, 2005 at 10:07:17PM +0200, Roland Smith wrote:
>>>>On Sun, Oct 23, 2005 at 03:09:51PM -0400, stan wrote:
>>>>> I'm trying to get procmail to rewrite the TO: header. I've tried 
>>>>> something like:
>>>>>
>>>>> TO=`formail -xTo:`
>>
>>      :0 Hf
>>      * X-Virus-Status: Yes
>>      | sed -e 's/^[sS]ubject:[[:space:]]\+/Subject: [virus] '
>
> Mmm, we are close here I put in:
>
> # test
> :0 Hf
> | sed -e 's/^[tT]o:[[:space:]]\+/To: [STAN] '
>
> (Unconditional to test the action).

That's plainly wrong.  The "To:" header will contain broken crap instead
of a recipient address.  Just *DON'T* do that.  Try to modify the
"Subject:" instead.  I'm positively sure than even the crapware from a
well-known Redmond-based company can filter based on the subject of
individual posts.

> But I got this error in the procmail logfile:
>
> sed: 1: "s/^[tT]o:[[:space:]]\+/ ...": unescaped newline inside substitute 
> pattern

It may be that procmail does weird things with the regexp string or that
procmail doesn't accept extended regexps (I think I remember finding out
about this one a while ago).  Let's see:

% flame:/home/keramida$ cd /tmp/stan/
% flame:/tmp/stan$ ls -l
% total 6
% -rw-------  1 keramida  wheel  - 4109 Oct 24 02:13 mbox
% flame:/tmp/stan$ cat > procmailrc
% :0 Hf
% | sed -e 's/^[tT]o:[[:space:]]\+/To: [STAN] '
% flame:/tmp/stan$ formail -s procmail /tmp/stan/procmailrc < mbox | grep -i to:
% sed: 1: "s/^[tT]o:[[:space:]]\+/ ...": unescaped newline inside substitute 
pattern
% flame:/tmp/stan$

When I avoid using the \+ trick, it works fine:

% flame:/tmp/stan$ cat > procmailrc
% :0 Hf
% | sed -e 's/^[tT][oO]:[[:space:]][[:space:]]*\([^[:space:]]\)/To: [STAN] \1/'
%
% :0
% /tmp/stan/newbox
% flame:/tmp/stan$ formail -s procmail /tmp/stan/procmailrc < mbox
% flame:/tmp/stan$ ls -l
% total 14
% -rw-------  1 keramida  wheel  - 4109 Oct 24 02:13 mbox
% -rw-------  1 keramida  wheel  - 4116 Oct 24 02:20 newbox
% -rw-rw-r--  1 keramida  wheel  -  105 Oct 24 02:19 procmailrc
% flame:/tmp/stan$ diff -u mbox newbox
% --- mbox        Mon Oct 24 02:13:03 2005
% +++ newbox      Mon Oct 24 02:20:05 2005
% @@ -36,7 +36,7 @@
%         for <[EMAIL PROTECTED]>; Sun, 23 Oct 2005 19:11:03 -0400
%  Date: Sun, 23 Oct 2005 19:11:03 -0400
%  From: stan <[EMAIL PROTECTED]>
% -To: Giorgos Keramidas <[EMAIL PROTECTED]>
% +To: [STAN] Giorgos Keramidas <[EMAIL PROTECTED]>
%  Subject: Re: procmail/formail syntax question
%  Message-ID: <[EMAIL PROTECTED]>
%  References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> 
<[EMAIL PROTECTED]>

So it *does* work, using plain regexps and not extended regexps and it
changes the To: header as expected (even though that's wrong, as I said
above).

- Giorgos

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to