Autor: W B Hacker Data: A: exim users Assumpte: Re: [exim] Exim4 pipe email through two commands
David Hoepelman wrote: > Hi,
> I currently have a few adresses that are set up as follows (in a aliases file):
>
> someemail: "|/usr/bin/somecommand -opt someoption"
>
> However, I would like the message to pass through another command
> first, much like normal shell pipeling:
>
> user@computer: echo "someemailcontents" | /usr/bin/somefilter -n 5 |
> /usr/bin/somecommand -opt someoption
>
> There are a couple of ways I imagine I could do this:
> 1. hardcode the second command in the first script (=> saving all the
> output and calling the command with that output on its input
> afterwards)
> 2. Modify the aliases file so that the mail goes through 2 commands
> (like shell pipelining)
> 3. Modify the router in the config file so all email of that router
> will go through that filter first (all the "special" adresses are in a
> seperate router directive)
>
> However I do not know if 2 or 3 is possible with exim4. Can anyone
> enlighten me on this?
>
> Thanks,
> David
>
As usual, here are several ways that will work...
'1' works- but... nothing to do with Exim.
'2' - chaining scripts in the ~/aliases file, should be essentially a 'don't
care' situation to Exim. Probably so even if one or more scripts ends up sending
back into Exim.
But I've never had a need to try this, so 'CAVEAT' - SWAG only.
'3' the use of bespoke router/transport sets AND NOT using the 'ordinary'
aliases file gets my vote. It would be only marginally harder to set up, but
potentially less work to maintain over time.
That partly because the addresses to be actioned could be held in a flat-file or
DB that Exim can read, but one that other (non-root) staff or daemons might be
allowed to alter. Manually OR automagically. That can be made so for a non
'system' (/etc/aliases) aliases-*style* file with appropriately altered perms,
... but those can perhaps be more hazardous. Too general-purpose, nore 'capable'
of doing the unwanted/unexpected...
A lookup 'hit' could be used to set an acl_m flag or X-header in an acl for
later use by router/transports, AND/OR/ELSE they can do their own lookups. So
long as either the acl or router you want to trigger is actually *traversed*.
See 'unseen' for chaining routers.... (perhaps also 'shadow transport')
.. and also 'no_verify', 'errors_to', and 'debug_print', one or all of which
might be helpful.
DISCLAIMER: applies to 'vanilla' Exim monobloc '~/configure'.
'Should' work the same in an Exim4 with split config, but not my ken where or
how to apply the necessaries..