I have setup email on free-pbx 17 debian host. Email on voicemail is working as expected. Then I went to “Settings → Voicemail Admin → Settings → Email Config” and changed Mail Command to “/usr/sbin/sendmail-custom” which is a shell script:
#!/bin/sh
# Get absolute path to the script's directory
script_dir="$(cd "$(dirname "$0")" && pwd)"
# Generate timestamped filename
timestamp=$(date +"%Y%m%d_%H%M%S")
outfile="$script_dir/email_$timestamp.txt"
# Read email from stdin, save to file, and print
cat - | tee "$outfile"
The file has these permissions:
namei -l /usr/sbin/sendmail-custom
drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root sbin
-rwxr-xr-x asterisk asterisk sendmail-custom
For some reasons, my shell script is never called. I am expecting a file to be created in the current working directory. What am I missing here?