You can create the router that use pipe transport with your script on the other side of pipe:
begin routers
preprocessor:
driver = accept
condition = if{ !eq{$header_X-Preproceeded}{yes}}
transport = myscript
no_more
. . . . .
begin transports
myscript:
driver = pipe
user = scriptowner
command = /path/to/script --opt1 --opt2
If incoming message does not have X-Preproceeded
header or its value doesn't set to yes
then message is passed to the myscript
transport. That is performed via piping source | script
and all the message is passed to the script's stdin
. After proceeding if you want to return proceeded message to the exim, you should add the x-Preproceeded: yes
header to the message to prevent it to be routed to the next lap. Then you have to submit it via sendmail
command.
#!/bin/sh
. . . .
mandatory_empty_line = ''
cat << ENDOFTEXT | /usr/sbin/sendmail -t
$headers
X_Preproceeded: yes
$mandatory_empty_line
$message_body
ENDOFTEXT
Keep in mind that effective user running script should be added to the trusted users by exim's config to allow sending from arbitrary address. Otherwise exim
will replace any sender's address by scriptowner@mydomain.tld