I need to run a shell script under exim that can read each incoming e-mail, optionally rewrites them and then continues sending the email.
And ideal solution would be analogous to UNIX pipes:
cat *incoming email* | **some-script.sh** | *back to exim processing*
I want the script to run very early, so that I can for example change the destination address.
Is this possible with Exim, and how?
You can create the router that use pipe transport with your script on the other side of pipe:
If incoming message does not have
X-Preproceeded
header or its value doesn't set toyes
then message is passed to themyscript
transport. That is performed via pipingsource | script
and all the message is passed to the script'sstdin
. After proceeding if you want to return proceeded message to the exim, you should add thex-Preproceeded: yes
header to the message to prevent it to be routed to the next lap. Then you have to submit it viasendmail
command.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[email protected]