This must be a full path. If the path starts with a tilde (~), then you must first convert it to a full path using the Filter, Expand tilde (~) paths action before the Execute Shell Script action.
I tried it with the full path as well. Now have attempted using $HOME, but the error is persisting.
I wonder if osascript opening URL mailto is a clue? Is KM seeing mailto in the command and trying to open a mailto: url instead of allowing emate to handle this?
emate (specifically the --send-now flag) likely relies on AppleScript to tell the Mail app to click "Send." Without /usr/bin in your path, the script doesn't know where osascript is.
#!/bin/zsh
# 1. Add standard system paths (/usr/bin is where osascript lives) and your home/bin to the PATH.
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/bin:$PATH"
# 2. Run emate
emate mailto
--from "xxx@gmail.com"
--to "xxx@gmail.com"
--subject "$KMVAR_VarName"
--markup "lorem ipsum"
--send-now
No -- that's for when you are passing a path via a KM variable. The ~ will work fine for that line of the shell script, but adds the user's top-level bin directory, which doesn't help here.
You're sorted, but for future reference -- you've edited or deleted the KM ENV_PATH Global variable. By default that is set to
/usr/bin:/bin:/usr/sbin:/sbin
...so your shell script should have found osascript. Check the variable by going to KM's "Settings" then the "Vaariables" pane -- you'll save a lot of future problems if you make sure at least those default paths are present.