We are configuring an Exim4
router with driver = queryprogram
, with the idea to execute a script and redirect certain addresses based on the script's logic.
The problem is that when debugging how exim would route the address, we get a my_router router: command returned non-zero code 127
error.
Why is exim getting a command returned non-zero code 127
? How can we fix this?
Thanks!
Here is some -hopefully- useful info:
# exim -d -bt [email protected]
...
--------> my_router router <--------
local_part=anaddress domain=mylocaldomain
checking local_parts
anaddress in "! root"? yes (end of list)
R: my debug message
calling my_router router
my_router router called for [email protected]: domain = mylocaldomain.com
requires uid=1001 gid=1001 current_directory=/tmp
direct command:
argv[0] = /tmp/myscript.sh
direct command after expansion:
argv[0] = /tmp/myscript.sh
my_router router: defer for [email protected]
message: my_router router: command returned non-zero code 127
[email protected] cannot be resolved at this time: my_router router: command returned non-zero code 127
search_tidyup called
>>>>>>>>>>>>>>>> Exim pid=8094 terminating with rc=1 >>>>>>>>>>>>>>>>
The script (/tmp/myscript.sh) that processes the mail is just
#/usr/bin/php
echo 'redirect another_address@another_domain.com';
exit;
The script has permissions
$ ls /tmp
total 196K
4.0K -rwxrwxr-x 1 someuser somegroup 58 Oct 5 20:48 myscript.sh
The router is configured in exim4.conf.template
as:
...
my_router:
debug_print = "R: my debug message"
driver = queryprogram
command = /tmp/myscript.sh
current_directory = /tmp
command_user = myuser
# domains = +local_domains
local_parts = ! root
cannot_route_message = Unknown Special user
You have a typo in the script: bang is omitted after the hash.
Exit code 127 means that appropriate interpreter is not found as far as shebang line is malformed.
Also I'm not sure you really want your script to be interpreted by PHP. So may be you have to replace first line with
#!/bin/sh