Re: [exim] Pre-processing incoming mail

Top Page
Delete this message
Reply to this message
Author: John Hall
Date:  
To: Jaap Winius
CC: Exim-users
Subject: Re: [exim] Pre-processing incoming mail
On 3/26/06, Jaap Winius <jwinius@???> wrote:

> What would be the best way to pre-process incoming messages? By this I
> mean that I'd like to single out certain messages and run one or more
> search-and-replace routines over them before they're delivered.
>
> For instance, I could write a perl script with some regular expressions
> to do what I want, but then how would I get Exim to pipe these messages
> through my script before delivery? Or would PCRE be a better choice?


Jaap,

I do something like this to implement a customer support system. I
have an accept router that uses a pipe transport to pipe the mail to
my perl script using batch SMTP. My perl script re-injects the message
into exim using BSMTP also.

Here are some fragements from my exim.conf:

# Router for incoming support e-mail - the first time in mail to
support gets piped.
support_in:
driver = accept
domains = +local_domains
local_parts = support
transport = support_transport_in
# this condition stops the re-injected e-mail being sent through the
pipe again
condition = "${if eq{$received_protocol}{support-filtered}{0}{1}}"


# Transport to handle incoming support requests
support_transport_in:
driver = pipe
user = mail
group = mail
command = /usr/local/bin/support_in
log_output
use_bsmtp
batch_max = 100


Finally, the script uses this code to re-inject the message with the
correct received_protocol:

open BSMTP, "| /usr/sbin/exim -oMr support-filtered -bS"

Regards,
John