Project: mhrw
Purpose: mailheader manipulation / rewrite engine
Version: 0.8
Author : Stephan Seitz <s.seitz@netz-haut.de>
License: GNU GPLv2
Introduction
============
mhrw is a tool for mailheader manipulation, sometimes neccessary in MTA's.
In general, headers shouldn't be rewritten, but i found myself configuring
an MTA with special delivery methods, where delivery took place depending
on spamassassin's spam-level and various other things.
In this setup, smtpd and delivery were completely different tasks without
any communication possible between them. So, i decided to use the mail-
headers loading some additional neccessary information. To get rid of lots
of slow scripts, mhrw was born. :)
How it works
============
mhrw reads mails from <stdin> or (if argument is given) from <file>.
It supports three 'operating modes',
a) replace some part of the header, matched by a regular expression,
b) add some part to the header below the former last headerline.
c) pipe the content through a given command if a reguler expression
matches.
In no way the body of a message is touched. Anything below the header is
passed through. Also, the message will always pass until EOF.
Examples
========
a) replace some part of the header:
-----------------------------------
To show some example, on how to use mhrw, i'll define the following (not
really standard, but very simple) mail as origin:
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|X-Authenticated-SMTP: username
|Received: anyhost; date
|Subject: some test
|
|body
|...
If this mailalike header is getting used by following command:
mhrw '^X-Authenticated-SMTP: .*$' ''
this will result in:
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|Received: anyhost; date
|Subject: some test
|
|body
|...
You're able to use any regular expression you like, limited (by default)
upto 4 subqueries.
The second argument (the replacement string) interprets written \n and \r
sequences.
b) add some part to the header:
-------------------------------
Adding something to the header is a really simple. Assuming, we're using
the above header, here's the example of two commands with output:
mhrw --add 'X-MRHW-modified: yes'
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|X-Authenticated-SMTP: username
|Received: anyhost; date
|Subject: some test
|X-MRHW-modified: yes
|
|body
|...
mhrw --pre 'X-MRHW-modified: yes'
|X-MRHW-modified: yes
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|X-Authenticated-SMTP: username
|Received: anyhost; date
|Subject: some test
|
|body
|...
c) pipe the content through a given command if a reguler expression matches:
----------------------------------------------------------------------------
This is a very handy feature, if the mail needs to be processed by another
command if some header matches the regular expression.
Here's an example:
mhrw '^X-Untrusted-User: .*$' '|spamc'
Here, the message is piped through spamc (a shell is spawned to execute this),
if '^X-Untrusted-User: .*$' matches the header. In all cases the message
finally arrives at <stdout>.
WARNING! There's a potentially loss of messages, if the given command cannot
execute or breaks the message. If mhrw is able to detect an error, it delivers
directly to <stdout>.
Installation
============
mhrw doesn't relay on libraries and is written with a very basic set of
commands, so:
./configure
make
make install
should build the binary on most platforms.
Problems/Bugs
=============
If You think, there is a bug or a problem with mhrw, don't hesitate to
mail me at <s.seitz@netz-haut.de>
Updates/latest Version
======================
This software is hosted at our CVS Server. If you're lucky, there'll be
a new release.
$ cvs -d :pserver:anoncvs@cvs.netz-haut.net:/home/cvs/ login
Password: anoncvs
$ cvs -d :pserver:anoncvs@cvs.netz-haut.net:/home/cvs/ co mhrw
Goodies
=======
Another small tool, named 'fsize' has been added to this package.
It's purpose is very simple. Get the size of a file and report it on
stdout.
fsize should explain itself.
Project: mhrw
Purpose: mailheader manipulation / rewrite engine
Version: 0.8
Author : Stephan Seitz <s.seitz@netz-haut.de>
License: GNU GPLv2
Introduction
============
mhrw is a tool for mailheader manipulation, sometimes neccessary in MTA's.
In general, headers shouldn't be rewritten, but i found myself configuring
an MTA with special delivery methods, where delivery took place depending
on spamassassin's spam-level and various other things.
In this setup, smtpd and delivery were completely different tasks without
any communication possible between them. So, i decided to use the mail-
headers loading some additional neccessary information. To get rid of lots
of slow scripts, mhrw was born. :)
How it works
============
mhrw reads mails from <stdin> or (if argument is given) from <file>.
It supports three 'operating modes',
a) replace some part of the header, matched by a regular expression,
b) add some part to the header below the former last headerline.
c) pipe the content through a given command if a reguler expression
matches.
In no way the body of a message is touched. Anything below the header is
passed through. Also, the message will always pass until EOF.
Examples
========
a) replace some part of the header:
-----------------------------------
To show some example, on how to use mhrw, i'll define the following (not
really standard, but very simple) mail as origin:
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|X-Authenticated-SMTP: username
|Received: anyhost; date
|Subject: some test
|
|body
|...
If this mailalike header is getting used by following command:
mhrw '^X-Authenticated-SMTP: .*$' ''
this will result in:
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|Received: anyhost; date
|Subject: some test
|
|body
|...
You're able to use any regular expression you like, limited (by default)
upto 4 subqueries.
The second argument (the replacement string) interprets written \n and \r
sequences.
b) add some part to the header:
-------------------------------
Adding something to the header is a really simple. Assuming, we're using
the above header, here's the example of two commands with output:
mhrw --add 'X-MRHW-modified: yes'
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|X-Authenticated-SMTP: username
|Received: anyhost; date
|Subject: some test
|X-MRHW-modified: yes
|
|body
|...
mhrw --pre 'X-MRHW-modified: yes'
|X-MRHW-modified: yes
|Received: somehost (somehost.somewhere) by uid 1007 with esmtp
|X-Authenticated-SMTP: username
|Received: anyhost; date
|Subject: some test
|
|body
|...
c) pipe the content through a given command if a reguler expression matches:
----------------------------------------------------------------------------
This is a very handy feature, if the mail needs to be processed by another
command if some header matches the regular expression.
Here's an example:
mhrw '^X-Untrusted-User: .*$' '|spamc'
Here, the message is piped through spamc (a shell is spawned to execute this),
if '^X-Untrusted-User: .*$' matches the header. In all cases the message
finally arrives at <stdout>.
WARNING! There's a potentially loss of messages, if the given command cannot
execute or breaks the message. If mhrw is able to detect an error, it delivers
directly to <stdout>.
Installation
============
mhrw doesn't relay on libraries and is written with a very basic set of
commands, so:
./configure
make
make install
should build the binary on most platforms.
Problems/Bugs
=============
If You think, there is a bug or a problem with mhrw, don't hesitate to
mail me at <s.seitz@netz-haut.de>
Updates/latest Version
======================
This software is hosted at our CVS Server. If you're lucky, there'll be
a new release.
$ cvs -d :pserver:anoncvs@cvs.netz-haut.net:/home/cvs/ login
Password: anoncvs
$ cvs -d :pserver:anoncvs@cvs.netz-haut.net:/home/cvs/ co mhrw
Goodies
=======
Another small tool, named 'fsize' has been added to this package.
It's purpose is very simple. Get the size of a file and report it on
stdout.
fsize should explain itself.