Skip to content

Instantly share code, notes, and snippets.

@magnetikonline
Last active November 7, 2017 10:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save magnetikonline/6059512 to your computer and use it in GitHub Desktop.
Save magnetikonline/6059512 to your computer and use it in GitHub Desktop.
Bash script to write/sink output sent to sendmail to a log file. Useful for debugging with PHP and other runtimes that talk to sendmail.
#!/bin/bash -e
# For PHP5 and /etc/php5/php.ini you would setup like so:
# sendmail_path = "/path/to/sendmailsink.sh"
LOG_FILE="/var/log/sendmailsink"
echo "$(date "+%Y-%m-%d @ %H:%M:%S") || $0 $*" >>$LOG_FILE
echo >>$LOG_FILE
while read buffer
do
echo "$buffer" >>$LOG_FILE
done
echo "=================================" >>$LOG_FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment