Re: [exim] Processing messages with an external program (scr…

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Phil Pennock
Date:  
À: Renaud Allard
CC: exim-users, Konstantin Boyandin
Sujet: Re: [exim] Processing messages with an external program (script)
On 2008-04-15 at 09:21 +0200, Renaud Allard wrote:
> Konstantin Boyandin wrote:
> > Greetings,
> >
> > I need to pass outgoing (outgoing only) message to an external
> > program, to make certain header transformations (namely, canonize
> > certain To/From addresses) prior to their being actually sent. Could
> > someone offer me the hints on how to do that?
> >
> > The program/script expects message on stdin and sends modified message
> > to stdout for further processing/delivery.
> >
>
> It is relatively easy.
> You can create a touter which calls a "custom" transport.
>
> The router could look like this:
> mypipe_router:
>         domains         = internal.domain.tld
>         driver          = accept
>         require_files   = /home/example/mycommand
>         local_part_suffix_optional
>         transport       = newspipe


This will send the mail to the program and that will be the end of it.
If the program called by newspipe/mypipe then invokes Exim to resend the
mail, then this would work. You could then use "exim -oMr foo" to set
the $received_protocol to "foo" and then on mypipe_router have:
condition = ${if eq{$received_protocol}{foo} {no}{yes}}
so that when resubmitted the mail won't be immediately just sent back
into this rewriter.

Note though that Exim has some fairly powerful capabilities for
rewriting To and From headers already, in the rewrites section. See the
Exim Specification (spec.txt with Exim, or on www.exim.org):
31. Address rewriting
and note that the replacement string is subject to string expansion and
so has the full power of Exim's string expansions available, including
database lookups, talking to sockets, invoking embedded Perl, etc.

Alternatively, to use the rewriting program which is already in use,
setting a transport_filter on the remote_smtp transport comes closest to
doing what was originally requested. Search for "transport_filter" in
the docs; it's described in:
24. Generic options for transports
together with the limitations, examples, etc.

-Phil