Re: [exim] Running a hook on successful delivery

Top Page
Delete this message
Reply to this message
Author: W B Hacker
Date:  
To: exim users
Subject: Re: [exim] Running a hook on successful delivery
Bernd Jendrissek wrote:
>
> [Back to exim-users as I am subscribed]


*trimmed*

>> Providing, of course, you asked Exim to log that in the first place.
>>
>> See log_selector =
> Yes, we have that in mainlog: log_selector = +sender_on_delivery
> +smtp_confirmation
>
> And yes, if I can't find an exim.conf way, I'll just run a regex in a
> daemon.
>> Otherwise, you could hang a file-write or SQL insert onto the transport.
> That's exactly what I want to do. But I can't find a suitable point of
> control. shadow_condition would have been my vector for exim.conf abuse
> if it were useable for remote shadows...
>
> Here's the relevant bit of our exim.conf:
>
> smart_routing:
> driver = manualroute
> transport = remote_smtp
> route_data = ${lookup pgsql{select * from
> "priGetSmartHosts"('${quote_pgsql:$sender_address_domain}')}{${sg{$value}{\n}{:}}}}
>
>
> dnslookup:
> driver = dnslookup
> domains = ! +local_domains
> transport = remote_smtp
> ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8
> no_more
>
> begin transports
>
> remote_smtp:
> driver = smtp
>
> And somehow I want to run 'select * from "priLogDelivery"($h_x-mailid:)'
> when remote_smtp gets a 2xx response. Or even any response, as long as
> my stored procedure gets to see the response code.
>
> How do I do this? Your "Otherwise, you could" makes me think there IS a
> way, just that I haven't RTFM enough. Any pointers please?


*trimmed*

Perhaps you've missed this, but my posts usually say 'an SQL call',
rarely do I say 'an SQL SELECT'
.

Duooooh moment, perhaps, but an INSERT or an UPDATE work just as
seamlessly as a SELECT - as do more complex combinations.

Here's one we use to populate a relation that gives us an idea as to
how effective various OTHER local filters have been over time:


set acl_c19 = ${lookup pgsql{INSERT into brownlist \
        (pg_when, pg_why, pg_ip, pg_host, pg_where) \
                    VALUES 
('$tod_log','DYN','$sender_host_address','$sender_host_name','$dnslist_domain')}}



Line breaks modified due to expected MUA buggery...



That one is in an acl that has just done a call to dynamic-IP RBL.

As reads "DYN", we also have "LBL", "RBL", and such in other places that
do Local and Remote BL checks ... and more.... much more.

All part of the 'telemetry' I refer to as an 'instrumented' server.

As SQL calls are incredibly flexible anywhere in Exim, BUT NOT
'lightweight', resource-wise, we comment these out once we have enough
in the way of metrics to vet what we are doing, ELSE support changes.

HTH,

Oh - BTW - also suggest that *many* SELECT calls can benefit,
security-wise from the addition of 'LIMIT 1' - just in case the DB has
gotten dodgy records into it that might return several, or even serve as
wildcards.


Bill