How can I log all emails going through sSMTP?

I can point my applications to a wrapper script, I just don't know how to write a wrapper script which logs headers and contents to a file (as much information as possible).

Thanks! :-)

4 Answers 4


sSMTP has debug logging built in. In your ssmtp.conf file, include the following line: Debug=YES

When debug logging is active, the entire contents of emails sent via sSMTP, including headers, is logged to syslog.

  • 2
    the ssmtp.conf man page doesn't mention this parameter :/
    – cweiske
    Nov 21, 2017 at 10:15
  • Syslog file is usually here in Ubuntu: /var/log/syslog Sep 8, 2020 at 21:33

The following should work as an sSMTP wrapper script. It logs the parameters it is called with and the data provided on stdin. Change the logfile location and name of the real sSMTP as appropriate.

set -e
LOGFILE="/tmp/ssmtp-$(date +%Y%m%d-%H%M%S-$$)"
echo "$0 $@" > "$LOGFILE"
tee -a "$LOGFILE" | ssmtp.real "$@"

Remember to make the script executable:

chmod +x /path/to/script

  • Can I log the response from Amazon to the log file as well? Oct 4, 2012 at 9:32

My working solution is: ssmtp -d9 <email-recipient>.


Why don't you just have your SMTP server log all of the messages received, hence capture the entire message?

If you use an external server you could just setup a simple internal server that then relays to the external server.

  • 2
    I use Amazon SES, which doesn't provide logging. I thought sSMTP was that simple internal server? Jul 3, 2012 at 19:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .