Re: [Exim] Looking at each email sent out

Top Pagina
Delete this message
Reply to this message
Auteur: Andreas J Mueller
Datum:  
CC: exim-users
Onderwerp: Re: [Exim] Looking at each email sent out
Hi Dan!

> Any idea off the top of your head where in the docs I should look?
> If not don't worry I'll find it, I just needed a shove in the right =
> direction.


About logging:
44.13 Summary of Fields in Log Lines
44.15 Reducing or increasing what is logged

About system filters:
39. System-wide message filtering

I just found this in the Exim spec: 41.9 Taking copies of mail
It talks about something called a shadow transport, which I'm not
(yet) familiar with.

>> - A system filter that acts on sender's domain and does an unseen
>> delivery to a pipe (if $sender_address_domain is "..." then unseen
>> deliver |/home/external_program.pl endif).
>
> Where would I do this? In the exim.pl file?


No, in a special Exim filter file. Basically you have to set

system_filter = /path/to/exim/system_filter
system_filter_user = <user to run the filter under>
system_filter_pipe_transport = address_pipe

in the mail Exim configuration. The system filter will be applied
once to every message, no matter how many recipients the message has.
Unfortunately, it will also be applied every time a new delivery is
attempted for deferred messages. A condition "first_delivery" is
available to check for the latter.

>> - A redirect router that acts on sender's domain and does an unseen
>> route to a pipe transport:
>>
>>     driver = redirect
>>     senders = domain.com
>>     data = |/home/external_program.pl
>>     no_verify
>>     no_expn
>>     pipe_transport = address_pipe
>>     unseen


> I like this option best since I already parse email a lot. And I might
> not parse the log file right and miss something.


After reading the spec some more, I would prefer the system filter
solution. The redirect router is run for every recipient address.
That means, if a message from domain.com is sent to 20 recipients, it
will be looked at 20 times. But unlike the system filter, it will not
be looked at for every retry, because routing is only done once per
message.

> Excuse the Exim newbie question, but where would I put those lines
> above (exim.conf ??)


In the exim.conf file, at the very start of the routers section. And
you need to name the router, e.g., archive_route: (note the colon).

> And that would send the email into 'data''s STDIN and then continue
> processing as if nothing happened for any email being sent from
> domain.com?


Yes, but you should make some more adjustments. Replace
pipe_transport = address_pipe
with
pipe_transport = archive_pipe

Then create an archive_pipe transport in the transports section of the
exim.conf file:

  archive_pipe:
    driver = pipe
    current_directory = /cwd/of/external_program.pl
    home_directory = /home/of/external_program.pl
    user = <user to run external_program.pl under>
    group = <group to run external_program.pl under>


This sets up the environment that your script is run under.  Second,
you may need to replace
    data = |/home/external_program.pl
with
    data = |/bin/sh -c /home/external_program.pl
 or data = |/usr/bin/perl /home/external_program.pl


because Exim might not recognize that external_program.pl is an
(executable) script. Again, I like the system filter idea a little
better, or the thing with the shadow transport that I'm not familiar
with. ;-)

Andy