Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Change Subject for specified email recipient - SOLVED

975 views
Skip to first unread message

Petr Svacina

unread,
Nov 5, 2007, 7:42:47 AM11/5/07
to

> &gt; My script seems to be OK. Because it's change the Subject only:<br />
> &gt; So sed commands are OK too: sed -i '/Subject/s/:.*/:SPEDICE/g'<br />
> &gt; Here is the test message:<br />
> <br />
> Try my reply as a test message instead. You'll find that any line (headers
<br />
> or body) with the word &quot;Subject&quot; and a : character (anywhere in
the line, <br />
> not only right behind) gets changed.<br />

I know. I know. But In my case it doesn't matter. really. And I am not able
to make it better .. :-)
I don't know how to write a script, which can go through message to change
ONLY FIRST word "Subject" and let rest like it is without a change ...
And email to this specific recipient will be send in Czech language, so
there should be no any other Subject .. :-)

Can anyone know how to make a better filter ? How to change the right
subject only in the header of the message ?

header_checks - know how to make it, but for only one user a need this and
header_checks can not handle this.
maildrop - can not change any subject to another and even if mialdrop know
this, so I have to replace maildrop like the MDA, but I use dovecot for
this, why another monster application ...
dovecot sieve - can not change subject , can lot of things but not this ...

Can be header_checks used somehow like a filter ? To set up postfix access
to use specific header_checks for ONE exact recipient only ????

mouss

unread,
Nov 5, 2007, 9:08:38 AM11/5/07
to
Petr Svacina wrote:
>> &gt; My script seems to be OK. Because it's change the Subject only:<br />
>> &gt; So sed commands are OK too: sed -i '/Subject/s/:.*/:SPEDICE/g'<br />
>> &gt; Here is the test message:<br />
>> <br />
>> Try my reply as a test message instead. You'll find that any line (headers
> <br />
>> or body) with the word &quot;Subject&quot; and a : character (anywhere in
> the line, <br />
>> not only right behind) gets changed.<br />
>
> I know. I know. But In my case it doesn't matter. really. And I am not able
> to make it better .. :-)
> I don't know how to write a script, which can go through message to change
> ONLY FIRST word "Subject" and let rest like it is without a change ...
> And email to this specific recipient will be send in Czech language, so
> there should be no any other Subject .. :-)
>
> Can anyone know how to make a better filter ? How to change the right
> subject only in the header of the message ?
>

Use reformail. it comes with maildrop.

...
reformail=/path/to/reformail
cat | $reformail -R Subject: X-Subject: -A "Subject: SPEDICE" > in.$$
...

This will rename the original Subject header and appends a new one.

> header_checks - know how to make it, but for only one user a need this and
> header_checks can not handle this.
> maildrop - can not change any subject to another

in mailroprc, you need to use reformail as shown above.

> and even if mialdrop know
> this, so I have to replace maildrop like the MDA, but I use dovecot for
> this, why another monster application ...

> dovecot sieve - can not change subject , can lot of things but not this ...
>
> Can be header_checks used somehow like a filter ? To set up postfix access
> to use specific header_checks for ONE exact recipient only ????

only if you are willing to run a dedicated smtpd for that recipient...

Petr Svacina

unread,
Nov 5, 2007, 4:03:59 PM11/5/07
to
>
> Use reformail. it comes with maildrop.
>
> ...
> reformail=/path/to/reformail
> cat | $reformail -R Subject: X-Subject: -A "Subject: SPEDICE" > in.$$
> ...

Not work .. It totally destroy incoming email ... :

Return-Path:
Received: by game.centel.cz (Postfix, from userid 1011)
id 6713C51610; Mon, 5 Nov 2007 21:52:58 +0100 (CET)
Message-Id: <200711052052...@game.centel.cz>
Date: Mon, 5 Nov 2007 21:52:58 +0100 (CET)
From: fr...@from.cz
To: undisclosed-recipients:;

This works:

/usr/local/bin/reformail -R Subject: X-Subject: -A "Subject: SPEDICE"
<test.message

but not perfect ..

1. change subject (ok)
2. If X-Subjcet is not present in original message, so it will create
X-Subject WITH orig. subject ! (wrong)

:-( Mayby I slould try to make a dedicated smtpd for that client .....
But I must learn how .. :-)


Thanks Peter

mouss

unread,
Nov 5, 2007, 7:12:03 PM11/5/07
to
Petr Svacina wrote:
>>>> cat | $reformail -R Subject: X-Subject: -A "Subject: SPEDICE" > in.$$
>>>> ...
>>> Not work .. It totally destroy incoming email ... :
>>>
>>> Return-Path:
>>> Received: by game.centel.cz (Postfix, from userid 1011)
>>> id 6713C51610; Mon, 5 Nov 2007 21:52:58 +0100 (CET)
>>> Message-Id: <200711052052...@game.centel.cz>
>>> Date: Mon, 5 Nov 2007 21:52:58 +0100 (CET)
>>> From: fr...@from.cz
>>> To: undisclosed-recipients:;
>>>
>>> This works:
>>>
>>> /usr/local/bin/reformail -R Subject: X-Subject: -A "Subject: SPEDICE"
>>> <test.message
>>>
>> and what is the difference with what I suggested?
>
> You suggested this: cat | $reformail -R Subject: X-Subject: -A "Subject:
> SPEDICE" > in.$$ - but this destroy (empty) email ..
> This works: cat | $reformail -R Subject: X-Subject: -A "Subject: SPEDICE" <
> in.$$ - this prints corectlly message to the standart output console
>

I was referring to the first cat, the one that writes the message to in.$$:

# Start processing.
cd $INSPECT_DIR || {
echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

cat >in.$$ || {
echo Cannot save mail to file; exit $EX_TEMPFAIL; }


do you see it?

> But when I use it in the filter , change will not happen ... Grrr. Why I
> can not ANY scripting language ?....
>
> Here is the full script:
>
> #!/bin/sh
>
> # Simple shell-based filter. It is meant to be invoked as follows:
> # /path/to/script -f sender recipients...
>
> # Localize these. The -G option does nothing before Postfix 2.3.
> REFORMAIL=/usr/local/bin/reformail
> INSPECT_DIR=/var/spool/filter
> SENDMAIL="/usr/sbin/sendmail -G -i" # NEVER NEVER NEVER use "-t" here.
>
> # Exit codes from <sysexits.h>
> EX_TEMPFAIL=75
> EX_UNAVAILABLE=69
>
> # Clean up when done or when aborting.
> trap "rm -f in.$$" 0 1 2 3 15
>
> # Start processing.
> cd $INSPECT_DIR || {
> echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
>
> cat >in.$$ || {
> echo Cannot save mail to file; exit $EX_TEMPFAIL; }
>
> # Specify your content filter here.
> cat | $REFORMAIL -R Subject: X-Subject: -A "Subject: SPEDICE" < in.$$ || {
> echo Message content rejected; exit $EX_UNAVAILABLE; }
> $SENDMAIL "$@" <in.$$
>

1- what's this "cat" for?
2- you are reading in.$$, modifying it in memory, and the modifications
are lost after exit!

> exit $?


>
>
>>> but not perfect ..
>>>
>>> 1. change subject (ok)
>>> 2. If X-Subjcet is not present in original message, so it will create
>>> X-Subject WITH orig. subject ! (wrong)

>> This was intentional (I don't like removing headers!). just remove the
>> -R part and use -U.
>
> OK. OK. I see
>
> Thanks Peter
>
>
>
>

Petr Svacina

unread,
Nov 6, 2007, 10:32:03 AM11/6/07
to

>
> I was referring to the first cat, the one that writes the message to
in.$$:
>
> # Start processing.
> cd $INSPECT_DIR || {
> echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }
>
> cat >in.$$ || {
> echo Cannot save mail to file; exit $EX_TEMPFAIL; }
>
>
> do you see it?
>

Yeah !!! I have forgotten, that reformail works a little bit different than
sed.
So I have removed first cat and now filter works perfect ...

THANKS very much for your help and for the time that you have to spend with
me ... :-)
Thanks a lot ... :-)

Bye Peter ....


lrp...@gmail.com

unread,
Jan 2, 2008, 5:54:37 PM1/2/08
to

Can you or somebody else post the entire solution? The script, the
changes in postfix, etc.

I would appreciate.

thks

paiva

0 new messages