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-Preproceededheader or its value doesn't set toyesthen message is passed to themyscripttransport. That is performed via pipingsource | scriptand 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: yesheader to the message to prevent it to be routed to the next lap. Then you have to submit it viasendmailcommand.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
eximwill replace any sender's address by[email protected]