procmailrc forwarding mail with altered subject

procmailrc forwarding mail with altered subject

am 15.04.2005 22:57:52 von selder21

Hello,

I have a procmailrc file which states that all mail with x in the To:
header will be send to another user y. Now what i would like to have is
that this user y, gets the exact same message as x, but with a modified
subject, e.g. :

To: x
Subject: hellow

becomes

To: y
Subject: Got from x: hellow

Thus, just an concatenation of the original subject with some extra
info.

I was hoping someone here has made something like this already in his
setup and could easily help me out. Thanks in advance.

Re: procmailrc forwarding mail with altered subject

am 15.04.2005 23:16:38 von Jem Berkes

> To: y
> Subject: Got from x: hellow
>
> Thus, just an concatenation of the original subject with some extra
> info.
>
> I was hoping someone here has made something like this already in his
> setup and could easily help me out. Thanks in advance.

In general, you'll want to use formail to help you change the Subject line.
For instance, if you pipe your mail through

formail -I "Subject: whatever"

This will will replace the previous subject with the new one. But you have
the additional challenge of reading the existing Subject. You'll probably
need a shell script to do this, you could grep for ^Subject: to pick out
the existing Subject line.

--
Jem Berkes
Software design for Windows and Linux/Unix-like systems
http://www.sysdesign.ca/

Re: procmailrc forwarding mail with altered subject

am 16.04.2005 02:03:38 von Alan Clifford

On Fri, 15 Apr 2005, selder21@hotmail.com wrote:

s> I have a procmailrc file which states that all mail with x in the To:
s> header will be send to another user y. Now what i would like to have is
s> that this user y, gets the exact same message as x, but with a modified
s> subject, e.g. :
s>

Untested but built from a recipe for a poor man's email-to-sms which I
used. You might have problems with the -f ${FROMHEADER} so perhaps you
should leave it out. You might not want the carbon copy 'c' either. The
x-loop is there because the email came back to me again - you might not
need that.


FROMHEADER=`formail -c -rtz -x To:`
OLD_SUBJECT=`formail -zx Subject:`

:0
* ^TO_xxxxxx@clifford.ac
* ! ^x-loop: xxxxxx@clifford.ac
{
:0 fhw
| formail -A "X-Loop: xxxxxx@clifford.ac" \
-I"Subject: Got from ${FROMHEADER}: ${OLD_SUBJECT}"

:0 c
| $SENDMAIL -oi -f ${FROMHEADER} yyyyyy@orange.net
}

--
Alan

( If replying by mail, please note that all "sardines" are canned.
There is also a password autoresponder but, unless this a very
old message, a "tuna" will swim right through. )

Re: procmailrc forwarding mail with altered subject

am 16.04.2005 03:16:48 von Nobody

"selder21@hotmail.com" wrote in
<1113598672.634777.196570@l41g2000cwc.googlegroups.com>:

| I have a procmailrc file which states that all mail with x in the To:
| header will be send to another user y. Now what i would like to have is
| that this user y, gets the exact same message as x, but with a modified
| subject, e.g. :
|
| To: x
| Subject: hellow
|
| becomes
|
| To: y
| Subject: Got from x: hellow
|
| Thus, just an concatenation of the original subject with some extra
| info.

:0c
* ^To:(.*\<)?x
* ^Subject:\/.*
| formail -I "Subject: Got from x:$MATCH" | $SENDMAIL $SENDMAILFLAGS y


--
David W. Tamkin

The reply address is bluelighted until 0500 UTC on 23Apr2005.

Re: procmailrc forwarding mail with altered subject

am 16.04.2005 03:56:09 von Timo Salmi

Jem Berkes wrote:
> In general, you'll want to use formail to help you change the Subject line.
> For instance, if you pipe your mail through
> formail -I "Subject: whatever"

> This will will replace the previous subject with the new one. But you have
> the additional challenge of reading the existing Subject. You'll probably
> need a shell script to do this, you could grep for ^Subject: to pick out
> the existing Subject line.

The -I option in formail removes and replaces the old header. Should one
wish to retain the old subject header with an "Old-" prefix added, use
-i instead. One migth be able to utilize this fact to avoid the need of
a separate shell script.

All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:ts@uwasa.fi ; FIN-65101, Finland
Timo's procmail tips at http://www.uwasa.fi/~ts/info/proctips.html

Re: procmailrc forwarding mail with altered subject

am 16.04.2005 21:32:06 von Jem Berkes

> FROMHEADER=`formail -c -rtz -x To:`
> OLD_SUBJECT=`formail -zx Subject:`

If you're extracting fields like this, depending on what you intend to do
later with that variable you might also want to sanitize it and remove any
special shell characters. I think,

OLD_SUBJECT=`formail -czx Subject: | sed -e 's/[;\$\`\\<>|]/ /g'`

Untested.

--
Jem Berkes
Software design for Windows and Linux/Unix-like systems
http://www.sysdesign.ca/